标签:模式 audit data source ISE mis repo multipart javascrip
由于Fetch API是基于Promise设计,因此旧的浏览器并不支持该API,需要引用时引用es6-promise。
基本知识
AcceptAccept-LanguageContent-LanguageContent-TypeGETHEADPOSTAccept-CharsetAccept-EncodingAccess-Control-Request-HeadersAccess-Control-Request-MethodConnectionContent-LengthCookieCookie2DateDNTExpectHostKeep-AliveOriginRefererTETrailerTransfer-EncodingUpgradeVia在请求中设置任何一个以上请求头时,浏览器会报错
index.html:16 Refused to set unsafe header "Accept-Encoding"
也就是说,这些属性只能被浏览器控制。
可选值:
-same-origin
只能同域名内访问。
-no-cors
no-cors模式下,heades基本不可修改,只有部分字段支持修改
1.Accept
2.Accept-Language
3.Content-Language
4.Content-Type只能设置为application/x-www-form-urlencoded,multipart/form-data和text-plain中的任意一种。
no-cors模式下,限制使用GET,HEAD,POST方法。
-cors
safari在6.1+版本里,通过window.fetch内置实现了fetch。
当请求仅包含以下几种情况时属于简单请求,浏览器不会下发预请求:
除跨域简单请求外的任何请求,客户端默认发送options预请求。
例外
针对以下非简单请求所属content-type可选值,服务端允许不通过预请求直接访问:
application/csp-reportapplication/reportapplication/expect-ct-report+jsonapplication/xss-auditor-reportapplication/ocsp-request标签:模式 audit data source ISE mis repo multipart javascrip
原文地址:https://www.cnblogs.com/wanxiong/p/js-ecma6-fetch.html