https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers
HTTP 消息头允许客户端和服务器通过 request和 response传递附加信息。 一个请求头由不区分大小写的名称后跟一个冒号“:”,然后跟然后值(不带换行符)组成。 该值前面的引导空白会被忽略。
http://www.tutorialspoint.com/http/http_header_fields.htm
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
fetch('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest',{
method: 'get',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Api-Key': `0987b00e542141369049e647701b65d9`
}
})
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(error) {
console.log('parsing failed: ', error)
});
fetch('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=0987b00e542141369049e647701b65d9')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(error) {
console.log('parsing failed: ', error)
});
https://gist.github.com/xgqfrms-GitHub/d8afbd6484cf10da3603c6f51d6d4907
Content-Type
在响应中,Content-Type标头告诉客户端实际返回的内容的内容类型。
浏览器会在某些情况下进行MIME嗅探,并不一定遵循此标题的值;
为了防止这种行为,可以将标题 X-Content-Type-Options 设置为 nosniff。
在请求中 (如POST 或 PUT),客户端告诉服务器实际发送的数据类型。
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Type
Access-Control-Request-Headers
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Request-Headers
Access-Control-Request-Method
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Request-Method
Response.headers
https://developer.mozilla.org/zh-CN/docs/Web/API/Response/headers
Headers
出于安全考虑,某些头只能由用户代理控制。这些头信息包括 forbidden header names 和 forbidden response header names。
https://developer.mozilla.org/zh-CN/docs/Web/API/Headers
Response/headers
https://developer.mozilla.org/zh-CN/docs/Web/API/Response/headers