@@ -96,9 +96,9 @@ async function fetchText() {
96
96
` Response.type ` 属性返回请求的类型。可能的值如下:
97
97
98
98
- ` basic ` :普通请求,即同源请求。
99
- - ` cors ` :跨域请求 。
99
+ - ` cors ` :跨源请求 。
100
100
- ` error ` :网络错误,主要用于 Service Worker。
101
- - ` opaque ` :如果` fetch() ` 请求的` type ` 属性设为` no-cors ` ,就会返回这个值,详见请求部分。表示发出的是简单的跨域请求 ,类似` <form> ` 表单的那种跨域请求 。
101
+ - ` opaque ` :如果` fetch() ` 请求的` type ` 属性设为` no-cors ` ,就会返回这个值,详见请求部分。表示发出的是简单的跨源请求 ,类似` <form> ` 表单的那种跨源请求 。
102
102
- ` opaqueredirect ` :如果` fetch() ` 请求的` redirect ` 属性设为` manual ` ,就会返回这个值,详见请求部分。
103
103
104
104
** Response.redirected**
@@ -455,19 +455,19 @@ const response = fetch(url, {
455
455
456
456
` mode ` 属性指定请求的模式。可能的取值如下:
457
457
458
- - ` cors ` :默认值,允许跨域请求 。
458
+ - ` cors ` :默认值,允许跨源请求 。
459
459
- ` same-origin ` :只允许同源请求。
460
- - ` no-cors ` :请求方法只限于 GET、POST 和 HEAD,并且只能使用有限的几个简单标头,不能添加跨域的复杂标头 ,相当于提交表单、` <script> ` 加载脚本、` <img> ` 加载图片等传统的跨域请求方法 。
460
+ - ` no-cors ` :请求方法只限于 GET、POST 和 HEAD,并且只能使用有限的几个简单标头,不能添加跨源的复杂标头 ,相当于提交表单、` <script> ` 加载脚本、` <img> ` 加载图片等传统的跨源请求方法 。
461
461
462
462
** credentials**
463
463
464
464
` credentials ` 属性指定是否发送 Cookie。可能的取值如下:
465
465
466
- - ` same-origin ` :默认值,同源请求时发送 Cookie,跨域请求时不发送 。
467
- - ` include ` :不管同源请求,还是跨域请求 ,一律发送 Cookie。
466
+ - ` same-origin ` :默认值,同源请求时发送 Cookie,跨源请求时不发送 。
467
+ - ` include ` :不管同源请求,还是跨源请求 ,一律发送 Cookie。
468
468
- ` omit ` :一律不发送。
469
469
470
- 跨域请求发送 Cookie,需要将` credentials ` 属性设为` include ` 。
470
+ 跨源请求发送 Cookie,需要将` credentials ` 属性设为` include ` 。
471
471
472
472
``` javascript
473
473
fetch (' http://another.com' , {
@@ -539,11 +539,11 @@ fetch('/page', {
539
539
- ` no-referrer-when-downgrade ` :默认值,总是发送` Referer ` 标头,除非从 HTTPS 页面请求 HTTP 资源时不发送。
540
540
- ` no-referrer ` :不发送` Referer ` 标头。
541
541
- ` origin ` :` Referer ` 标头只包含域名,不包含完整的路径。
542
- - ` origin-when-cross-origin ` :同源请求` Referer ` 标头包含完整的路径,跨域请求只包含域名 。
543
- - ` same-origin ` :跨域请求不发送 ` Referer ` ,同源请求发送。
542
+ - ` origin-when-cross-origin ` :同源请求` Referer ` 标头包含完整的路径,跨源请求只包含域名 。
543
+ - ` same-origin ` :跨源请求不发送 ` Referer ` ,同源请求发送。
544
544
- ` strict-origin ` :` Referer ` 标头只包含域名,HTTPS 页面请求 HTTP 资源时不发送` Referer ` 标头。
545
- - ` strict-origin-when-cross-origin ` :同源请求时` Referer ` 标头包含完整路径,跨域请求时只包含域名 ,HTTPS 页面请求 HTTP 资源时不发送该标头。
546
- - ` unsafe-url ` :不管什么情况,总是发送` Referer ` 标头。
545
+ - ` strict-origin-when-cross-origin ` :同源请求时` Referer ` 标头包含完整路径,跨源请求时只包含域名 ,HTTPS 页面请求 HTTP 资源时不发送该标头。
546
+ - ` unsafe-url ` :不管什么情况,总是发送` Referer ` 标头。
547
547
548
548
## 取消` fetch() ` 请求
549
549
@@ -597,4 +597,3 @@ try {
597
597
- [ Using Fetch] ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch )
598
598
- [ Javascript Fetch API: The XMLHttpRequest evolution] ( https://developerhowto.com/2019/09/14/javascript-fetch-api/ )
599
599
- [ A Guide to Faster Web App I/O and Data Operations with Streams] ( https://www.sitepen.com/blog/2017/10/02/a-guide-to-faster-web-app-io-and-data-operations-with-streams/ )
600
-
0 commit comments