http协议

http请求数据解析
请求的数据里面包含三个部分内容 : 请求行 、 请求头 、请求体

  • 请求行

      POST /examples/servlets/servlet/RequestParamExample HTTP/1.1 
    
      POST : 请求方式 ,以post去提交数据
      	
      /examples/servlets/servlet/RequestParamExample
      请求的地址路径 , 就是要访问哪个地方。
    
      HTTP/1.1 协议版本
    
  • 请求头

      Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*
      Referer: http://localhost:8080/examples/servlets/servlet/RequestParamExample
      Accept-Language: zh-CN
      User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
      Content-Type: application/x-www-form-urlencoded
      Accept-Encoding: gzip, deflate
      Host: localhost:8080
      Content-Length: 31
      Connection: Keep-Alive
      Cache-Control: no-cache
    

    Accept: 客户端向服务器端表示,我能支持什么类型的数据。
    Referer : 真正请求的地址路径,全路径
    Accept-Language: 支持语言格式
    User-Agent: 用户代理 向服务器表明,当前来访的客户端信息。
    Content-Type: 提交的数据类型。经过urlencoding编码的form表单的数据
    Accept-Encoding: gzip, deflate : 压缩算法 。
    Host : 主机地址
    Content-Length: 数据长度
    Connection : Keep-Alive 保持连接
    Cache-Control : 对缓存的操作

  • 请求体
    浏览器真正发送给服务器的数据
    发送的数据呈现的是key=value ,如果存在多个数据,那么使用 &

      firstname=zhang&lastname=sansan
    

http响应数据解析

	HTTP/1.1 200 OK
	Server: Apache-Coyote/1.1
	Content-Type: text/html;charset=ISO-8859-1
	Content-Length: 673
	Date: Fri, 17 Feb 2017 02:53:02 GMT

响应行

	HTTP/1.1 200 OK
	协议版本
		HTTP/1.1
	状态码 
		200 :  成功,正常处理,得到数据。
		403 :  for bidden  拒绝
		404 : Not Found
		500 : 服务器异常
	OK
		对应前面的状态码  

响应头

	Server:  服务器是哪一种类型。  Tomcat
	Content-Type : 服务器返回给客户端你的内容类型
	Content-Length : 返回的数据长度
	Date : 通讯的日期,响应的时间

post请求会使用流的方式写数据,get请求是在地址栏后加数据。
post请求使用流的方式写数据,所以一定需要一个Content-Length的头来说明数据长度。
get能带的数据有限,1kb大小。post没有数据大小限制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值