Skip to content

Commit 7af63ff

Browse files
committed
minor
1 parent fd0f108 commit 7af63ff

File tree

4 files changed

+46
-41
lines changed

4 files changed

+46
-41
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ For cross-origin request, by default JavaScript may only access so-called "simpl
174174
- `Last-Modified`
175175
- `Pragma`
176176
177-
Any other response header is forbidden.
177+
Accessing any other response header causes an error.
178178
179179
```smart header="Please note: no `Content-Length`"
180180
Please note: there's no `Content-Length` header in the list!
181181

182182
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).
183183
```
184184
185-
To grant JavaScript access to any other response header, the server must list it in the `Access-Control-Expose-Headers` header.
185+
To grant JavaScript access to any other response header, the server must send `Access-Control-Expose-Headers` header. It contains a comma-separated list of non-simple header names that should be made accessible.
186186
187187
For example:
188188
@@ -197,8 +197,7 @@ Access-Control-Expose-Headers: Content-Length,API-Key
197197
*/!*
198198
```
199199
200-
With such `Access-Control-Expose-Headers` header, the script is allowed to access `Content-Length` and `API-Key` headers of the response.
201-
200+
With such `Access-Control-Expose-Headers` header, the script is allowed to read `Content-Length` and `API-Key` headers of the response.
202201
203202
## "Non-simple" requests
204203
@@ -208,14 +207,15 @@ Some time ago no one could even assume that a webpage is able to do such request
208207
209208
So, to avoid misunderstandings, any "non-simple" request -- that couldn't be done in the old times, the browser does not make such requests right away. Before it sends a preliminary, so-called "preflight" request, asking for permission.
210209
211-
A preflight request uses method `OPTIONS` and has no body.
212-
- `Access-Control-Request-Method` header has the requested method.
210+
A preflight request uses method `OPTIONS`, no body and two headers:
211+
212+
- `Access-Control-Request-Method` header has the method of a non-simple request.
213213
- `Access-Control-Request-Headers` header provides a comma-separated list of non-simple HTTP-headers.
214214
215-
If the server agrees to serve the requests, then it should respond with status 200, without body.
215+
If the server agrees to serve the requests, then it should respond with empty body, status 200 and headers:
216216
217-
- The response header `Access-Control-Allow-Methods` must have the allowed method.
218-
- The response header `Access-Control-Allow-Headers` must have a list of allowed headers.
217+
- `Access-Control-Allow-Methods` must have the allowed method.
218+
- `Access-Control-Allow-Headers` must have a list of allowed headers.
219219
- Additionally, the header `Access-Control-Max-Age` may specify a number of seconds to cache the permissions. So the browser won't have to send a preflight for subsequent requests that satisfy given permissions.
220220
221221
![](xhr-preflight.svg)

5-network/05-fetch-crossorigin/xhr-another-domain.svg

Lines changed: 2 additions & 2 deletions
Loading

5-network/05-fetch-crossorigin/xhr-preflight.svg

Lines changed: 35 additions & 30 deletions
Loading

figures.sketch

1.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)