浠庨浂璁茶В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鍗忚的主要内容,如果未能解决你的问题,请参考以下文章

浠庨浂璧锋瀹炵幇闊充箰鎺ㄨ崘绯荤粺

娣卞叆鐞嗚В Http 鍜?Https

Echars璁茶В鍒嗘瀽

04_渚嬪瓙璁茶В锛歳lViewDemo.exe

璁茶ВMNTC 313

Dubbo婧愮爜璁茶В瑙嗛鏁欑▼