GET/POST请求头

先看看GET是啥样儿的

  GET /empty_project/inde.jsp HTTP/1.1
  Host: localhost:8088
  Connection: keep-alive
  Upgrade-Insecure-Requests: 1
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)       Chrome/55.0.2883.87 Safari/537.36
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Accept-Encoding: gzip, deflate, sdch, br
  Accept-Language: zh-CN,zh;q=0.8
  Cookie: pgv_pvi=4403687424

  • 请求行
  • 多个请求头信息 头名称:头值
    • Accept 浏览器支持的类型
    • Accept-Language 浏览器支持的语言
    • Accept-Encoding 浏览器支持的压缩格式
    • Host 请求的主机
    • Connection keep-alive 这个是链接一小段时间
  • 空行
  • 请求体

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=F463F5132A34573215C941893534BF26; Path=/empty_project; HttpOnly
Content-Type: text/html;charset=utf-8
Content-Length: 196
Date: Mon, 02 Jan 2017 08:52:48 GMT
  • 响应行 (协议/版本 状态码 状态码解析)
  • 响应头 (key/value格式)
  • 空行
  • 响应正文

看看post是啥样儿

POST /index.jsp HTTP/1.1
Host: localhost:8088
Connection: keep-alive
Content-Length: 35
Cache-Control: max-age=0
Origin: http://localhost:8088
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://localhost:8088/empty_project/login.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8
Cookie: pgv_pvi=4403687424

username=username&password=password
  • 主要是Content-Type 使用urlencoded
    • 转化为字节 -- 加上128 -- 转化为16进制 -- 添加%

POST /index.jsp HTTP/1.1
Host: localhost:8088
Connection: keep-alive
Content-Length: 252
Cache-Control: max-age=0
Origin: http://localhost:8088
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarySN8ehdkx6tF3Ngiq
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://localhost:8088/empty_project/login.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8
Cookie: pgv_pvi=4403687424; JSESSIONID=061657A0C03921CB478ACB889502C93A

------WebKitFormBoundarySN8ehdkx6tF3Ngiq
Content-Disposition: form-data; name="username"

sdfdsf
------WebKitFormBoundarySN8ehdkx6tF3Ngiq
Content-Disposition: form-data; name="password"

sdfdsfsdfdsf
------WebKitFormBoundarySN8ehdkx6tF3Ngiq--
  • 表单的enctypemultipart/form-data的时候

Nothing is certain in this life. The only thing i know for sure is that. I love you and my life. That is the only thing i know. have a good day

:)

你可能感兴趣的:(GET/POST请求头)