请求方法 请求url 协议版本\r\n
请求头
空白行\r\n
请求体

HTTP版本 状态码 状态码文本描述 \r\n
头部信息\r\n
\r\n
响应body
语法:数据格式,语义:规定所要完成的动作,同步:时序关系
<link rel="prefetch" href="">问题来了,get如何拿到最新数据,设置Cache-control, 参数添加随机数,换成Post
媒体类型 Multipurpose Internet Mail Extensions
通用结构type/subtype
表明文件是普通文本,理论上是人类可读
表明是某种二进制数据
多种类型组合
一般跟着boundary属性指定分割符,例如
Content-Type: multipart/form-data; boundary=aBoundaryString
每种类型会有Content-Type指定当前类型
请求头用来告知(服务器)客户端可以处理的内容类型
格式
Accept: type/subtype[;q=权重] [,type/subtype] [,type/*] [,*/*]告诉浏览器是否将将Credentials暴漏给前端的JS脚本
唯一有效值为true
一般用来解决跨域自动设置cookie问题,注意Access-Control-Allow-Origin不能为*
// 不使用缓存
Cache-Control: no-store
// 验证
Cache-Control: no-cache
Cache-Control: max-age=0, must-revalidate注意使用max-age=0时,若服务器无响应,则会使用缓存
Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-control: no-cache
Cache-control: no-store
Cache-control: no-transform
Cache-control: only-if-cachedCache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-control: no-cache
Cache-control: no-store
Cache-control: no-transform
Cache-control: only-if-cached指定资源的类型
当浏览器执行文件嗅探功能时,MIME sniff,可以使用
X-Content-Type-Options: nosniff关闭这一行为
格式
Content-Type: type/subtype[;charset=utf-8][;boundary=string(仅仅是multipart/form-data时)]options请求。一般以下格式
OPTIONS /path
Access-Control-Request-Method: Method //真正的请求方法
Access-Control-Request-Headers: origin, x-requested-with//真正请求头部
Origin: https://example.comReponse格式
HTTP/1.1 200 OK
Content-Length: 0
Connection: keep-alive
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://foo.bar.org
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Allow-Headers:
Access-Control-Max-Age: 86400