http

HTTP(超文本传输协议):规定数据的格式

  浏览器往服务器发送  ---  请求

  服务器往浏览器回写  ---  响应

  请求(request):

    组成部分:请求行、请求头、请求体

      请求行:请求信息的第一行

        格式:

          请求方式    访问资源   协议/版本

          例:GET   /yisen/1.html  HTTP/1.1

        请求方式:get   和   post

          get会把参数放在url后面   post不会

          get参数大小有限制,post请求没有限制

          get请求没有请求体,post请求有请求体  请求参数放在请求体中

      请求头:请求信息的第二行到空行结束

        格式:

          key/value格式(value可以是多个值)

        常见的请求头:

Accept: text/html,image/* --支持数据类型         text/html text/css text/javascript 大类型/小类型    mime类型
Accept-Charset: ISO-8859-1 --字符集
Accept-Encoding: gzip --支持压缩
Accept-Language:zh-cn --语言环境
Host: localhost:8080  --访问主机
If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT --缓存文件的最后修改时间
Referer: http://www.itcast.com/index.jsp --来自哪个页面、防盗链
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) ;--浏览器内核
Cookie
Connection: close/Keep-Alive --链接状态
Date: Tue, 11 Jul 2000 18:23:51 GMT --时间

        掌握的头信息:

          Referer   User-Agent   Cookie   If-Modified-Since

      请求体:空行一下内容

        只有post才由请求体   get请求参数   http://xxxx?username=tom&password=123

        格式:

          username=tom&password=123

  响应(response):

    组成部分:响应行、响应头、响应体

      响应行:响应信息的第一行

        格式:

          协议/版本   状态码   状态码说明

          例:HTTP/1.1   200   OK

        状态码:

          200   正常响应成功

          302   重定向

          304   读缓存

          404   用户操作资源不存在

          500   服务器内部异常

      响应头:从响应信息的第二行到空行结束

        格式:

          key/value格式(value可以是多个值)

        常见的响应头:

Location: http://www.it315.org/index.jsp --跳转方向    和302一起使用
Server:apache tomcat --服务器型号
Content-Encoding: gzip --数据压缩
Content-Length: 80 --数据长度
Content-Language: zh-cn --语言环境
Content-Type: text/html; charset=GB2312 --数据类型
Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT --最后修改时间
Refresh: 1;url=http://www.it315.org --定时刷新
Content-Disposition: attachment; filename=aaa.zip --下载
Set-Cookie:SS=Q0=5Lb_nQ; path=/search
Expires: -1 --缓存
Cache-Control: no-cache --缓存
Pragma: no-cache --缓存
Connection: close/Keep-Alive --连接
Date: Tue, 11 Jul 2000 18:23:51 GMT

        掌握的响应头:

          Content-Type   Location   Last-Modified   Content-Disposition   Set-Cookie

 

      响应体:空行以下的内容

        页面上展示的内容

posted @ 2020-08-02 14:45  Yisennnn丶  阅读(372)  评论(0编辑  收藏  举报