Skip to content

Commit 6bbe0b4

Browse files
committed
minor
1 parent 899ae4f commit 6bbe0b4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

5-network/04-fetch-crossorigin/article.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Let's say we need to get the data from `http://another.com` this way:
8686
humidity: 78
8787
});
8888
```
89-
4. As the script executes, `gotWeather` runs, and, as it's our function, we have the data.
89+
4. When the remote script loads and executes, `gotWeather` runs, and, as it's our function, we have the data.
9090
9191
9292
@@ -152,7 +152,7 @@ The browser plays the role of a trusted mediator here:
152152

153153
![](xhr-another-domain.png)
154154

155-
Here's an example of an "accepting" response:
155+
Here's an example of a permissive server response:
156156
```
157157
200 OK
158158
Content-Type:text/html; charset=UTF-8
@@ -177,7 +177,7 @@ Any other response header is forbidden.
177177
```smart header="Please note: no `Content-Length`"
178178
Please note: there's no `Content-Length` header in the list!
179179

180-
So, if we're downloading something and would like to track the percentage of progress, then an additional permission is required to access that header (see below).
180+
This header contains the full response length. So, if we're downloading something and would like to track the percentage of progress, then an additional permission is required to access that header (see below).
181181
```
182182
183183
To grant JavaScript access to any other response header, the server must list it in the `Access-Control-Expose-Headers` header.
@@ -233,11 +233,11 @@ let response = await fetch('https://site.com/service.json', {
233233
There are three reasons why the request is not simple (one is enough):
234234
- Method `PATCH`
235235
- `Content-Type` is not one of: `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`.
236-
- Custom `API-Key` header.
236+
- "Non-simple" `API-Key` header.
237237
238238
### Step 1 (preflight request)
239239
240-
The browser, on its own, sends a preflight request that looks like this:
240+
Prior to sending our request, the browser, on its own, sends a preflight request that looks like this:
241241
242242
```
243243
OPTIONS /service.json
@@ -260,9 +260,9 @@ The server should respond with status 200 and headers:
260260
- `Access-Control-Allow-Methods: PATCH`
261261
- `Access-Control-Allow-Headers: Content-Type,API-Key`.
262262
263-
That would allow future communication, otherwise an error is triggered.
263+
That allows future communication, otherwise an error is triggered.
264264
265-
If the server expects other methods and headers, makes sense to list them all at once, e.g:
265+
If the server expects other methods and headers in the future, makes sense to allow them in advance by adding to the list:
266266
267267
```
268268
200 OK
@@ -312,17 +312,17 @@ Why?
312312
313313
That's because a request with credentials is much more powerful than an anonymous one. If allowed, it grants JavaScript the full power to act and access sensitive information on behalf of a user.
314314
315-
Does the server really trust pages from `Origin` that much? A request with credentials needs an additional header to pass through.
315+
Does the server really trust pages from `Origin` that much? Then it must explicitly allow requests with credentials with an additional header.
316316
317-
To enable credentials, we need to add the option `credentials: "include"`, like this:
317+
To send credentials, we need to add the option `credentials: "include"`, like this:
318318
319319
```js
320320
fetch('http://another.com', {
321321
credentials: "include"
322322
});
323323
```
324324
325-
Now `fetch` sends cookies originating from `another.com` with the request.
325+
Now `fetch` sends cookies originating from `another.com` with out request to that site.
326326
327327
If the server wishes to accept the request with credentials, it should add a header `Access-Control-Allow-Credentials: true` to the response, in addition to `Access-Control-Allow-Origin`.
328328
@@ -356,10 +356,10 @@ So, practical difference is that simple requests are sent right away, with `Orig
356356
**For simple requests:**
357357
358358
- → The browser sends `Origin` header with the origin.
359-
- ← For requests without credentials (default), the server should set:
360-
- `Access-Control-Allow-Origin` to `*` or same as `Origin`
359+
- ← For requests without credentials (not sent default), the server should set:
360+
- `Access-Control-Allow-Origin` to `*` or same value as `Origin`
361361
- ← For requests with credentials, the server should set:
362-
- `Access-Control-Allow-Origin` to `Origin`
362+
- `Access-Control-Allow-Origin` to same value as `Origin`
363363
- `Access-Control-Allow-Credentials` to `true`
364364
365365
Additionally, if JavaScript wants to access non-simple response headers:

0 commit comments

Comments
 (0)