zoukankan      html  css  js  c++  java
  • javaWeb之http协议

    javaWeb之http协议

    1.http协议是什么?

      http协议(超文本传输协议)通俗地讲是一种网络数据传输格式,他规定了在一次交互中中请求和响应的数据格式,最终体现为网络传输的数据包格式,一次请求,一次响应

    2.请求

      请求包括:请求行    请求头   请求体

      请求行:

        格式 :      请求方式     资源路径      协议版本

         访问百度抓包请求行结果:

          

      请求头:

        在请求行结束之后key/value键值对

          Accept: text/html,image/* --支持数据类型
          Accept-Charset: ISO-8859-1 --字符集
          Accept-Encoding: gzip --支持压缩
          Accept-Language:zh-cn --语言环境
          Host: www.baidu.com:80 --访问主机
          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)    浏览器信息
          Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36
          Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0

          Connection: close/Keep-Alive --链接状态

          

      

    请求体:客户端传给服务器端的参数,post请求的参数就在这

          在请求头结束隔一行

    3.响应

       响应是服务器给客户端的回应

        包括:响应行     响应头     响应体

      响应行:

        格式:协议版本          状态码         状态码说明

          

          状态码:就是当前响应的概述
          1xx:表示服务器接收到请求了 但是数据还没准备好
          2xx:表示成功响应
            200
          3xx:表示需要用户进一步操作才能获取想要的资源
            304:缓存
            302:重定向
            location:跳转的地址

          4xx:用户错误
          404:地址输错了
          405:请求方式不对

          5xx:服务器端错误
          500:代码逻辑报错了

      响应头:

          在响应头结束后以键值对形式表现

          Location: http://www.it315.org/index.jsp --跳转方向
          Server:apache tomcat --服务器型号
          Content-Encoding: gzip --数据压缩
          Content-Length: 80 --数据长度
          Content-Language: zh-cn --语言环境
          Content-Type: text/html; charset=GB2312 --数据类型 大数据类型/小数据类型 image/png image/jpeg
          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 --连接

      响应体
        响应头结束隔一行
        存放就是你想要的响应正文

      

  • 相关阅读:
    oracle11G静默安装步骤
    [INS06101] IP address of localhost could not be determined
    linux tar命令使用详解
    centos 安装 Adobe Flash Player
    yum出错:Error: failure: repodata/filelists.xml.gz from googlechrome: [Errno 256] No more mirrors to try.
    sysbench安装与使用
    /usr/libexec/gconfsanitycheck2 退出状态256
    sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory
    Oracle11gR2 for Linux 静默安装
    error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or directory
  • 原文地址:https://www.cnblogs.com/xuzhaocai/p/8384783.html
Copyright © 2011-2022 走看看