JavaWeb筆記004 Http請求和響應

請求:(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
	響應體:空行以下的內容
		頁面上展示的內容
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章