JavaWeb笔记004 Http请求和响应

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lizhengwei1989/article/details/88411414
请求:(request)
	组成部分:
		请求行 请求头 请求体
		
	请求行:请求信息的第一行
		格式:请求方式	访问的资源 协议/版本
		例如:GET /projectname/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: www.itcast.cn: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)
			Cookie
			Connection:Keep-Alive   	--链接状态
			
		重要的头信息:
			Referer User-Agent Cookie If-Modified-Since
			
			
	请求体:
		只有post才有请求体  get请求参数 http://xxxx?username=tom&password=123
		对应于post请求:
		请求地址:http://xxxx
		请求体内容: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: Keep-Alive   			--连接
		比较重要的头信息
			Content-Type Location  Last-Modified Refresh Content-Disposition Set-Cookie
	响应体:空行以下的内容
		页面上展示的内容

猜你喜欢

转载自blog.csdn.net/lizhengwei1989/article/details/88411414
今日推荐