美文网首页
HTTP get post请求

HTTP get post请求

作者: liudai123 | 来源:发表于2017-10-17 17:56 被阅读12次

    1. GET方法

    //请求行 格式:请求方式 请求地址  协议名称/版本

    GET /http/userLogin.php?username=wanlum&password=123456 HTTP/1.1

    //请求头

    Host: localhost

    Connection: keep-alive

    Upgrade-Insecure-Requests: 1

    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8

    Referer: http://localhost/day02-http&ajax/4-code/02-http/userLogin.html

    Accept-Encoding: gzip, deflate, br

    Accept-Language: zh-CN,zh;q=0.8

    //请求正文

    username=json&password=123456

    2. POST方法

    //请求行 格式:请求方式 请求地址  协议名称/版本

    POST /http/userLogin.php HTTP/1.1

    //请求头

    代表主机名称

    Host: localhost

    代表是否开启长链接

    Connection: keep-alive

    代表请求内容的长度(中文一个占三个字节)

    Content-Length: 31

    是否开启缓存    开启缓存 但是立即删除

    Cache-Control: max-age=0

    域名的源

    Origin: http://localhost

    安全请求

    Upgrade-Insecure-Requests: 1

    用户代理

    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

    告诉服务器请求内容是表单的url的编码

    Content-Type: application/x-www-form-urlencoded

    浏览器告诉服务器我能接受的内容的类型

    image/png image/jpg  audio/mp3  我们把这样的格式  大类型/具体类型  叫做MIME类型

    作用是告诉对方用什么样的方式去解析内容

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9, image/webp,image/apng,*/*;q=0.8

    当前的页面是从那个页面跳转过来的()

    Referer: http://localhost/http/userLogin.html

    浏览器告诉服务器能接受的内容的压缩格式

    Accept-Encoding: gzip, deflate,

    浏览器告诉服务器我所能接受的语言

    Accept-Language: zh-CN,zh;q=0.8

    //请求正文

    username=json&password=123456

    相关文章

      网友评论

          本文标题: HTTP get post请求

          本文链接:https://www.haomeiwen.com/subject/iwaduxtx.html