浠庨浂璁茶ВHTTP鍗忚
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了浠庨浂璁茶ВHTTP鍗忚相关的知识,希望对你有一定的参考价值。
鏍囩锛?/p>
浠婂ぉ姝eソ鏈夋椂闂达紝灏辩粰澶у鍐欎竴鐐?/span>HTTP鍗忚鍏ラ棬鏁欑▼锛屼粠闆跺紑濮嬩负澶у璁茶В浠€涔堟槸HTTP鍗忚銆?/span>
涓€銆佷粈涔堟槸HTTP鍗忚
HTTP鏄?/span>hypertext transfer protocol锛堣秴鏂囨湰浼犺緭鍗忚锛夌殑绠€鍐欙紝瀹冩槸TCP/IP鍗忚鐨勪竴涓簲鐢ㄥ眰鍗忚锛屽畾涔変簡Web瀹㈡埛绔悜Web鏈嶅姟鍣ㄨ姹?/span>Web椤甸潰鐨勬柟寮忥紝浠ュ強鏈嶅姟鍣ㄥ悜瀹㈡埛绔紶閫?/span>Web椤甸潰鐨勬柟寮忋€?/span>
瀹氫箟涓殑鍚嶈瘝瑙i噴锛?/span>
浠€涔堟槸瓒呮枃鏈紵
瓒呮枃鏈槸鐢ㄨ秴閾炬帴鐨勬柟娉曪紝灏嗗悇绉嶄笉鍚岀┖闂寸殑鏂囧瓧淇℃伅缁勭粐鍦ㄤ竴璧风殑缃戠姸鏂囨湰銆?/span>
浠€涔堟槸搴旂敤灞傚崗璁紵
缃戠粶鐨勮璁¤€呬娇鐢ㄥ垎灞傜殑鏂瑰紡缁勭粐缃戠粶鍗忚浠ュ強瀹炵幇杩欎簺鍗忚鐨勭‖浠跺拰杞欢锛屽巻鍙蹭笂姣旇緝閲嶈鐨勪竴涓崗璁粍缁囨ā鍨嬫槸浜斿眰鍥犵壒缃戝崗璁爤锛屼粠椤跺眰鍒板簳灞傦紝鍒嗗埆涓哄簲鐢ㄥ眰銆佽繍杈撳眰銆佺綉缁滃眰銆侀摼璺眰銆佺墿鐞嗗眰銆傚叾涓簲鐢ㄥ眰甯歌鐨勫崗璁湁HTTP銆?/span>SMTP銆?/span>FTP绛夛紝杩愯緭灞傚崗璁湁TCP銆?/span>UDP绛夛紝缃戠粶灞傛湁IP绛夈€?/span>
浜屻€丠TTP鍗忚鐗圭偣
1. HTTP浣跨敤TCP浣滀负瀹冪殑杩愯緭灞傚崗璁紝TCP涓?/span>HTTP鎻愪緵鍙潬鏁版嵁浼犺緭鏈嶅姟銆備娇鐢ㄤ簡鍒嗗眰缁撴瀯锛?/span>HTTP鍗忚涓嶇敤鎷呭績鏁版嵁涓㈠け锛屼篃涓嶇敤鍏虫敞TCP浠庣綉缁滅殑鏁版嵁涓㈠け鍜屼贡搴忔晠闅滀腑鎭㈠鐨勭粏鑺傘€?/span>
2. HTTP鏄竴涓棤鐘舵€佸崗璁紝鏈嶅姟鍣ㄥ悜瀹㈡埛绔彂閫佽璇锋眰鐨勬枃浠讹紝鑰屼笉淇濆瓨浠讳綍鍏充簬璇ュ鎴风殑淇℃伅锛岋紙闇€瑕佷繚瀛樺垯搴斿綋浣跨敤cookie锛夈€?/span>
3. HTTP/1.0浣跨敤闈炴寔缁繛鎺ワ紝HTTP/1.1浣跨敤鎸佺画杩炴帴銆備娇鐢ㄦ寔缁繛鎺ワ紝鍦ㄥ鎴峰拰鏈嶅姟鍣ㄤ腑涓嶇敤澶氭鍒嗛厤TCP鐨勭紦鍐插尯鍜屼繚鎸?/span>TCP鍙橀噺锛屽悓鏃堕伩鍏嶄簡姣忎竴涓紶杈撳璞$殑涓ゅ€?/span>RTT浜や粯鏃跺欢銆?/span>HTTP鐨勯粯璁ゆā寮忔槸浣跨敤甯︽祦姘寸嚎鐨勬寔缁繛鎺ャ€?/span>
涓夈€丠TTP鎶ユ枃鏍煎紡
1. 璇锋眰鎶ユ枃
涓句緥濡備笅锛?/span>
GET /somedir/page.html HTTP/1.1
Host: www.someschool.edu
Connection: close
User-agent: Mozilla/5.0
Accept-language: fr
-------------------------------------------------------
First line: request line
Other lines: header line
璇锋眰琛岋細 鏂规硶瀛楁 - URL瀛楁 - HTTP鐗堟湰瀛楁
鍏朵腑锛屾柟娉曞瓧娈靛彲鍙朑ET, POST, HEAD, PUT, DELETE绛?/span>
榛樿涓篏ET璇锋眰锛屽湪URL鍚庨檮甯﹀弬鏁帮紝鏈夊ぇ灏忛檺鍒讹紝涓嶈秴杩?/span>1K
琛ㄥ崟鎻愪氦涓寚鏄庣敤POST鏃剁敤POST锛屽湪瀹炰綋涓紶閫掞紝鏃犲ぇ灏忛檺鍒?/span>
HEAD鏂规硶甯哥敤浜庤皟璇曪紝鍙繑鍥?/span>HTTP鎶ユ枃锛屼笉杩斿洖璇锋眰瀵硅薄
Connection: close琛ㄧず涓嶄娇鐢ㄦ寔缁繛鎺?/span>
甯歌鐨勮姹傚ご锛?/span>
Accept: text/html,image/* 瀹㈡埛鍙帴鍙楃殑鏁版嵁绫诲瀷
Accept-Charset: ISO-8859-1 鎺ュ彈鏁版嵁闇€瑕佷娇鐢ㄧ殑瀛楃闆嗙紪鐮?/span>
Accept-Encoding: gzip,compress 鎺ュ彈鐨勬暟鎹帇缂╂牸寮?/span>
Accept-Language: en-us,zh-cn 鎺ュ彈鐨勮瑷€鐜
Host: www.it315.org:80 铏氭嫙涓绘満鍚?/span>
If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT 缂撳瓨璧勬簮鐨勬渶鍚庤幏鍙栨椂闂?/span>
Referer: http://www.it315.org/index.jsp 褰撳墠鐨勮姹傛潵鑷摢涓摼鎺?/span>
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 褰撳墠鏃堕棿
2. 鍝嶅簲鎶ユ枃
涓句緥濡備笅锛?/span>
HTTP/1.1 200 ok
Connection: close
Date: Tue, 09 Aug 2011 15:44:04 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Tue, 09 Aug 2011 15:11:03 GMT
Content-Length: 6821
Content-Type: text/html
(Data, Data, Data ...)
-------------------------------------------------------
First line: status line
Last line: entity body
Other lines: header line
鐘舵€佽锛氬崗璁増鏈?nbsp;- 鐘舵€佺爜 - 鐘舵€佷俊鎭?/span>
鐘舵€佺爜鍜岀姸鎬佷俊鎭父瑙佺殑鏈夛細
200 OK
301 Moved Permanently
400 Bad Request
404 Not found
505 HTTP Version Not Supported
-------------------------------------------------------
100 ~ 199 琛ㄧず鎴愬姛鎺ユ敹锛屽鎴风闇€瑕佺户缁彁浜ゆ墠鑳藉畬鎴愭暣涓繃绋嬶紝200 ~ 299 琛ㄧず鎴愬姛鎺ユ敹骞跺凡瀹屾垚鏁翠釜杩囩▼
300 ~ 399 涓哄畬鎴愯姹傦紝瀹㈡埛闇€瑕佽繘涓€姝ョ粏鍖栬姹傦紝濡?/span>302璇锋眰閲嶅畾鍚戯紝304, 307 閫氱煡浣跨敤缂撳瓨
400 ~ 499 瀹㈡埛绔姹傛湁閿欒
500 ~ 599 鏈嶅姟鍣ㄧ鍑虹幇閿欒
甯歌鐨勫搷搴斿ご锛?/span>
Location: http://www.it315.org/index.jsp 閰嶅悎302瀹炵幇璇锋眰閲嶅畾鍚?/span>
Server:apache tomcat 鏈嶅姟鍣ㄧ殑鍩烘湰淇℃伅
Content-Encoding: gzip 鏈嶅姟鍣ㄥ彂閫佹暟鎹椂浣跨敤鐨勫帇缂╂牸寮?/span>
Content-Length: 80 鍙戦€佹暟鎹殑澶у皬
Content-Language: zh-cn 鍙戦€佹暟鎹娇鐢ㄧ殑璇█鐜
Content-Type: text/html; charset=GB2312 褰撳墠鎵€鍙戦€佺殑鏁版嵁鐨勫熀鏈俊鎭?/span>
Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT 缂撳瓨鐩稿叧
Refresh: 1;url=http://www.it315.org 瀹氭椂鍒锋柊鍒版煇涓?/span>URL
Content-Disposition: attachment;filename=aaa.zip 涓庝笅杞芥湁鍏崇殑澶?/span>
Transfer-Encoding: chunked 鏁版嵁浼犺緭绫诲瀷锛屾暟鎹竴鍧楀潡浼犺緭
Set-Cookie:SS=Q0=5Lb_nQ; path=/search 璁剧疆cookie
ETag: W/"83794-1208174400000" 鍜岀紦瀛樼浉鍏?/span>
Expires: -1 鎸囧畾璧勬簮缂撳瓨鐨勬椂闂达紝濡傛灉鍙栧€间负0鎴?/span>-1娴忚灏变笉缂撳瓨璧勬簮
Cache-Control: no-cache 濡傛灉涓?/span>no-cache鍒欓€氱煡娴忚鍣ㄤ笉缂撳瓨
Pragma: no-cache 濡傛灉涓?/span>no-cache鍒欓€氱煡娴忚鍣ㄤ笉缂撳瓨
鐢变簬鍘嗗彶鍘熷洜锛屼互涓婁笁涓兘鐢ㄦ潵鎺у埗缂撳瓨锛屽悓鏃朵娇鐢?/span>
Connection: close/Keep-Alive 鏄惁淇濇寔杩炴帴
Date: Tue, 11 Jul 2000 18:23:51 GMT 褰撳墠鏃堕棿
鍘熸枃鏉ヨ嚜锛?span style="font-family:Calibri;">Linux绀惧尯
以上是关于浠庨浂璁茶ВHTTP鍗忚的主要内容,如果未能解决你的问题,请参考以下文章