http headers总结

request header 中的属性


accept 客户端所可以接收的服务器所返回的数据类型(content-type)
Content-Type 请求的MIME Type
Origin 客户端的主域名,如果网页为http://www.example.com/v1/user 则为 www.example.com
referer 客户端的完整域名,
User-Agent 浏览器的信息
Access-Control-Request-Headers 告诉服务器,浏览器需要用到的header属性
X-Requested-With 用于分辨Ajax请求,angularjs默认为 XMLHttpRequest


response header中的属性
Access-Control-Allow-Origin 所允许访问的跨源域名
Access-Control-Allow-Methods 所允许访问的方法, post,put, get ,delete, options
Access-Control-Allow-Credentials 布尔值,是否允许浏览器发送cookie
Access-Control-Allow-Headers 允许浏览器request header中带的头部值
Status 200 OK, 401 UnAuthorization, 500 Internal Server exception, 301 page remove
如果使用token进行安全验证, 则浏览器每次的request都需要发送token,通常是将其值设置为Authorization头,因此服务器的所有response中必须设置Access-Control-Allow-Headers中包含 Authorization

在解决跨域问题时候, 一般设置: Access-Control-Allow-Origin, 还需要设置Access-Control-Allow-Headers 如果客户端自定义了header参数

浪漫家园,没事就来逛逛
原文地址:https://www.cnblogs.com/lovezbs/p/14454444.html