Skip to content

Commit 00f4493

Browse files
committed
Update "Fetch API" article
1 parent 1fd38d8 commit 00f4493

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

5-network/06-fetch-api/article.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ let promise = fetch(url, {
2121
// depending on the request body
2222
"Content-Type": "text/plain;charset=UTF-8"
2323
},
24-
body: undefined // string, FormData, Blob, BufferSource, or URLSearchParams
24+
body: undefined, // string, FormData, Blob, BufferSource, or URLSearchParams
2525
referrer: "about:client", // or "" to send no Referer header,
2626
// or an url from the current origin
27-
referrerPolicy: "no-referrer-when-downgrade", // no-referrer, origin, same-origin...
27+
referrerPolicy: "strict-origin-when-cross-origin", // no-referrer-when-downgrade, no-referrer, origin, same-origin...
2828
mode: "cors", // same-origin, no-cors
2929
credentials: "same-origin", // omit, include
3030
cache: "default", // no-store, reload, no-cache, force-cache, or only-if-cached
@@ -52,7 +52,7 @@ Usually that header is set automatically and contains the url of the page that m
5252

5353
**The `referrer` option allows to set any `Referer` (within the current origin) or remove it.**
5454

55-
To send no referer, set an empty string:
55+
To send no referrer, set an empty string:
5656
```js
5757
fetch('/page', {
5858
*!*
@@ -85,26 +85,26 @@ Unlike the `referrer` option that allows to set the exact `Referer` value, `refe
8585

8686
Possible values are described in the [Referrer Policy specification](https://w3c.github.io/webappsec-referrer-policy/):
8787

88-
- **`"no-referrer-when-downgrade"`** -- the default value: full `Referer` is always sent, unless we send a request from HTTPS to HTTP (to the less secure protocol).
88+
- **`"strict-origin-when-cross-origin"`** -- the default value: for same-origin send the full `Referer`, for cross-origin send only the origin, unless it's HTTPS→HTTP request, then send nothing.
89+
- **`"no-referrer-when-downgrade"`** -- full `Referer` is always sent, unless we send a request from HTTPS to HTTP (to the less secure protocol).
8990
- **`"no-referrer"`** -- never send `Referer`.
9091
- **`"origin"`** -- only send the origin in `Referer`, not the full page URL, e.g. only `http://site.com` instead of `http://site.com/path`.
9192
- **`"origin-when-cross-origin"`** -- send the full `Referer` to the same origin, but only the origin part for cross-origin requests (as above).
9293
- **`"same-origin"`** -- send the full `Referer` to the same origin, but no `Referer` for cross-origin requests.
9394
- **`"strict-origin"`** -- send only the origin, not the `Referer` for HTTPS→HTTP requests.
94-
- **`"strict-origin-when-cross-origin"`** -- for same-origin send the full `Referer`, for cross-origin send only the origin, unless it's HTTPS→HTTP request, then send nothing.
9595
- **`"unsafe-url"`** -- always send the full url in `Referer`, even for HTTPS→HTTP requests.
9696

9797
Here's a table with all combinations:
9898

9999
| Value | To same origin | To another origin | HTTPS→HTTP |
100100
|-------|----------------|-------------------|------------|
101101
| `"no-referrer"` | - | - | - |
102-
| `"no-referrer-when-downgrade"` or `""` (default) | full | full | - |
102+
| `"no-referrer-when-downgrade"` | full | full | - |
103103
| `"origin"` | origin | origin | origin |
104104
| `"origin-when-cross-origin"` | full | origin | origin |
105105
| `"same-origin"` | full | - | - |
106106
| `"strict-origin"` | origin | origin | - |
107-
| `"strict-origin-when-cross-origin"` | full | origin | - |
107+
| `"strict-origin-when-cross-origin"` or `""` (default) | full | origin | - |
108108
| `"unsafe-url"` | full | full | full |
109109

110110
Let's say we have an admin zone with a URL structure that shouldn't be known from outside of the site.
@@ -179,7 +179,7 @@ The `integrity` option allows to check if the response matches the known-ahead c
179179
180180
As described in the [specification](https://w3c.github.io/webappsec-subresource-integrity/), supported hash-functions are SHA-256, SHA-384, and SHA-512, there might be others depending on the browser.
181181
182-
For example, we're downloading a file, and we know that it's SHA-256 checksum is "abcdef" (a real checksum is longer, of course).
182+
For example, we're downloading a file, and we know that its SHA-256 checksum is "abcdef" (a real checksum is longer, of course).
183183
184184
We can put it in the `integrity` option, like this:
185185

0 commit comments

Comments
 (0)