HTTP1.1鍗忚涓枃鐗?RFC2616
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTTP1.1鍗忚涓枃鐗?RFC2616相关的知识,希望对你有一定的参考价值。
鏍囩锛?/p>
杞嚜锛?a href="http://www.cnpaf.net/Class/HTTP/200811/23277.html">http://www.cnpaf.net/Class/HTTP/200811/23277.html
璇存槑
鏈枃妗h瀹氫簡浜掕仈缃戠ぞ鍖虹殑鏍囧噯缁勫崗璁紝骞堕渶瑕佽璁哄拰寤鸿浠ヤ究鏇村姞瀹屽杽銆傝鍙傝€?/p>
“浜掕仈缃戝畼鏂瑰崗璁爣鍑?rdquo;锛圫TD 1锛夋潵浜嗚В鏈崗璁殑鏍囧噯鍖栫姸鎬併€傛湰鍗忚涓嶉檺娴佷紶鍙戝竷銆?/p>
鐗堟潈澹版槑
Copyright 锛圕锛?The Internet Society 锛?999锛? All Rights Reserved.
鎽樿
瓒呮枃鏈紶杈撳崗璁紙HTTP锛夋槸涓€绉嶄负鍒嗗竷寮忥紝鍚堜綔寮忥紝瓒呭獟浣撲俊鎭郴缁熴€傚畠鏄竴绉嶉€氱敤鐨勶紝鏃犵姸鎬侊紙stateless锛夌殑鍗忚锛岄櫎浜嗗簲鐢ㄤ簬瓒呮枃鏈紶杈撳锛屽畠涔熷彲浠ュ簲鐢ㄤ簬璇稿鍚嶇О鏈嶅姟鍣ㄥ拰鍒嗗竷瀵硅薄绠$悊绯荤粺涔嬬被鐨勭郴缁燂紝杩欏彲浠ラ€氳繃鎵╁睍瀹冪殑璇锋眰鏂规硶锛岄敊璇唬鐮佸拰鎶ュご[47]鏉ュ疄鐜般€侶TTP鐨勪竴涓壒鐐规槸鏁版嵁琛ㄧ幇褰㈠紡鏄彲杈撳叆鐨勫拰鍙崗鍟嗘€х殑锛岃繖灏卞厑璁哥郴缁熻兘琚缓绔嬭€岀嫭绔嬩簬鏁版嵁浼犺緭銆?nbsp;
HTTP鍦?990骞碬WW鍏ㄧ悆淇℃伅鍒氬垰璧锋鐨勬椂鍊欏氨寰楀埌浜嗗簲鐢ㄣ€傛湰璇存槑涔﹁缁嗛槓杩颁簡HTTP/1.1 鍗忚锛屾槸RFC 2068鐨勪慨璁㈢増[33]銆?/p>
鐩綍锛堢暐锛?/p>
1 寮曡
1.1 鐩殑
瓒呮枃鏈紶杈撳崗璁紙HTTP锛夋槸涓€绉嶄负鍒嗗竷寮忥紝鍚堜綔寮忥紝澶氬獟浣撲俊鎭郴缁熸湇鍔★紝闈㈠悜搴旂敤灞傜殑 鍗忚銆傚湪1990骞碬WW鍏ㄧ悆淇℃伅鍒氬垰璧锋鐨勬椂鍊橦TTP灏卞緱鍒颁簡搴旂敤銆侶TTP鐨勭涓€涓増鏈彨鍋欻TTP/0.9,鏄竴绉嶄负浜掕仈缃戝師濮嬫暟鎹紶杈撴湇鍔$殑绠€鍗曞崗璁€傜敱RFC 1945[6]瀹氫箟鐨凥TTP/1.0杩涗竴姝ュ畬鍠勪簡杩欎釜鍗忚銆傚畠鍏佽娑堟伅浠ョ被浼糓IME鐨勬牸寮忎紶閫侊紝鍖呮嫭鏈夊叧鏁版嵁浼犺緭鐨勭淮鎶や俊鎭拰鍏充簬璇锋眰/鍝嶅簲鐨勫彞娉曚慨姝c€備絾鏄紝HTTP/1.0娌℃湁鍏呭垎鑰冭檻鍒板垎灞備唬鐞嗭紝缂撳瓨鐨勪綔鐢ㄤ互鍙婂绋冲畾杩炴帴鍜岃櫄鎷熶富鏈虹殑闇€姹傘€傚苟涓旈殢鐫€涓嶅畬鍠勭殑搴旂敤绋嬪簭鐨勬縺澧烇紝HTTP/1.0杩垏闇€瑕佷竴涓柊鐨勭増鏈?浠ヤ究浣夸袱涓€氫俊搴旂敤绋嬪簭鑳藉纭畾褰兼鐨勭湡瀹炴€ц兘銆?/p>
杩欓噷瑙勫畾鐨勫崗璁彨鍋氭摟TTP/1.1".杩欎釜鍗忚涓嶩TTP/1.0鐩告瘮锛岃姹傛洿涓轰弗鏍硷紝浠ョ‘淇濆悇椤瑰姛鑳藉緱鍒板彲闈犲疄鐜般€?/p>
瀹為檯鐨勪俊鎭郴缁熼櫎浜嗙畝鍗曠殑妫€绱㈠锛岃姹傛洿澶氱殑鍔熻兘鎬э紙functionality锛夛紝鍖呮嫭鏌ユ壘锛坰earch锛夛紝鍓嶇鏇存柊锛坒ront-end update锛夊拰娉ㄨВ锛坅nnotation锛夈€侶TTP鍏佽鍙墿鍏呯殑鏂规硶闆嗗拰鎶ュご闆嗕互鎸囩ず璇锋眰鐨勭洰鐨刐47]銆傚畠鏄缓绔嬪湪缁熶竴璧勬簮鏍囪瘑绗︼紙URI锛塠3]鎻愪緵鐨勫湴鍧€锛圲RL锛塠4]鍜屽悕瀛楋紙URN锛変笂[20]锛屼互鎸囧嚭鏂规硶搴旂敤浜庡摢涓祫婧愮殑銆傛秷鎭互绫讳技浜庝竴绉嶅彨鍋氬鐢ㄩ€旂綉缁滈偖浠舵墿灞曪紙MIME锛塠7] 鐨勪簰鑱旂綉閭欢鐨勬牸寮忎紶閫併€?/p>
HTTP涔熸槸鐢ㄤ簬鐢ㄦ埛浠g悊涔嬮棿鍙婁唬鐞?缃戝叧鍒板叾浠栫綉缁滅郴缁熺殑閫氱敤閫氫俊鍗忚锛岃繖鏍风殑缃戠粶绯荤粺鍙兘鐢盨MTP[16],NNTP[13],FTP[18],Gopher[2]鍜學AIS[10]鍗忚鏀寔銆傝繖鏍凤紝HTTP鍏佽涓嶅悓鐨勫簲鐢ㄧ▼搴忓璧勬簮杩涜鍩烘湰鐨勮秴濯掍綋璁块棶銆?/p>
1.2 瑕佹眰
鏈枃鐨勫叧閿瘝"MUST", "MUST NOT", "REQUIRED", "SHALL","SHALL NOT","SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", 鍜?"OPTIONAL"灏嗙敱RFC 2119[34]瑙i噴銆?/p>
涓€涓簲鐢ㄧ▼搴忓鏋滀笉鑳芥弧瓒冲崗璁彁渚涚殑涓€涓垨澶氫釜MUST鎴朢EQUIRED绛夌骇鐨勮姹傦紝鏄笉绗﹀悎瑕佹眰鐨勩€備竴涓簲鐢ㄧ▼搴忓鏋滄弧瓒虫墍鏈塎UST鎴朢EQUIRED绛夌骇浠ュ強鎵€鏈塖HOULD绛夌骇鐨勮姹傦紝鍒欒绉颁负闈炴潯浠堕伒寰紙unconditionally compliant锛夌殑锛涜嫢婊¤冻鎵€鏈塎UST绛夌骇鐨勮姹備絾涓嶈兘婊¤冻鎵€鏈塖HOULD绛夌骇鐨勮姹傚垯琚О涓烘潯浠堕伒寰殑锛坈onditionally compliant锛夈€?/p>
1.3 鏈
鏈鏄庣敤鍒颁簡鑻ュ共鏈锛屼互琛ㄧずHTTP閫氫俊涓悇鍙備笌鑰呭拰瀵硅薄鎵紨鐨勪笉鍚岃鑹层€?/p>
杩炴帴锛坈onnection锛?/p>
涓洪€氫俊鑰屽湪涓や釜绋嬪簭闂村缓绔嬬殑浼犺緭灞傝櫄鎷熺數璺€?/p>
娑堟伅锛坢essage锛?/p>
HTTP閫氫俊涓殑鍩烘湰鍗曞厓銆傚畠鐢变竴涓粨鏋勫寲鐨勫叓姣旂壒瀛楄妭搴忓垪缁勬垚锛屼笌绗?绔犲畾涔夌殑鍙ユ硶鐩稿尮閰嶏紝骞堕€氳繃杩炴帴寰楀埌浼犻€併€?/p>
璇锋眰锛坮equest锛?/p>
涓€绉岺TTP璇锋眰娑堟伅锛屽弬鐪嬬5绔犵殑瀹氫箟銆?/p>
鍝嶅簲锛坮esponse锛?/p>
涓€绉岺TTP鍝嶅簲娑堟伅锛屽弬鐪嬬6绔犵殑瀹氫箟銆?/p>
璧勬簮锛坮esource锛?/p>
涓€绉嶇綉缁滄暟鎹璞℃垨鏈嶅姟锛屽彲浠ョ敤绗?.2鑺傚畾涔夌殑URI鎸囧畾銆傝祫婧愬彲浠ヤ互澶氱琛ㄧ幇鏂瑰紡锛堜緥濡傚绉嶈瑷€锛屾暟鎹牸寮忥紝澶у皬鍜屽垎杈ㄧ巼锛夋垨鑰呮牴鎹叾瀹冩柟闈㈣€岃€屼笉鍚岀殑琛ㄧ幇褰㈠紡銆?/p>
瀹炰綋锛坋ntity锛?/p>
瀹炰綋鏄姹傛垨鍝嶅簲鐨勬湁鏁堟壙杞戒俊鎭€備竴涓疄浣撳寘鍚厓淇℃伅鍜屽唴瀹癸紝鍏冧俊鎭互瀹炰綋澶村煙锛坋ntity-header field锛夊舰寮忚〃绀猴紝鍐呭浠ユ秷鎭富浣擄紙entity-body锛夊舰寮忚〃绀恒€傚湪绗?鑺傝杩般€?/p>
琛ㄧ幇褰㈠紡 锛坮epresentation锛?/p>
涓€涓搷搴斿寘鍚殑瀹炰綋鏄敱鍐呭鍗忓晢锛坈ontent negotiation锛夊喅瀹氱殑銆傚绗?2绔犳墍杩般€傛湁鍙兘瀛樺湪涓€涓壒瀹氱殑鍝嶅簲鐘舵€佺爜瀵瑰簲澶氫釜琛ㄧ幇褰㈠紡銆?/p>
鍐呭鍗忓晢锛坈ontent negotiation锛?/p>
褰撴湇鍔′竴涓姹傛椂閫夋嫨璧勬簮鐨勪竴绉嶉€傚綋鐨勮〃绀哄舰寮忕殑鏈哄埗锛坢echanism锛夛紝濡傜12鑺傛墍杩般€備换浣曞搷搴旈噷瀹炰綋鐨勮〃鐜板舰寮忛兘鏄彲鍗忓晢鐨勶紙鍖呮嫭鍑洪敊鍝嶅簲锛?
鍙橀噺锛坴ariant锛?/p>
鍦ㄤ换浣曠粰瀹氭椂鍒伙紝涓€涓祫婧愬搴旂殑琛ㄧ幇褰㈠紡锛坮epresentation锛夊彲浠ユ湁涓€涓垨澶氫釜锛堣瘧娉細涓€涓猆RI璇蜂竴涓祫婧愶紝浣嗚繑鍥炵殑鏄璧勬簮瀵瑰簲鐨勮〃鐜板舰寮忥紝杩欐牴鎹唴瀹瑰崗鍟嗗喅瀹氾級銆傛瘡涓〃鐜板舰寮忥紙representation锛夎绉颁綔涓€涓彉閲忋€備娇鐢ㄥ彉閲忚繖涓湳璇苟涓嶆槸鎰忓懗鐫€璧勬簮锛坮esource锛夋槸蹇呴』鐢卞唴瀹瑰崗鍟嗗喅瀹氱殑.
瀹㈡埛绔紙client锛?/p>
涓哄彂閫佽姹傚缓绔嬭繛鎺ョ殑绋嬪簭.
鐢ㄦ埛浠g悊锛坲ser agent锛?/p>
鍒濆鍖栬姹傜殑瀹㈡埛绔▼搴忋€傚父瑙佺殑濡傛祻瑙堝櫒,缂栬緫鍣?铚樿洓锛堢綉缁滅┛瓒婃満鍣ㄤ汉锛?鎴栧叾浠栫殑缁堢鐢ㄦ埛宸ュ叿.
鏈嶅姟鍣紙Server锛?/p>
鏈嶅姟鍣ㄦ槸杩欐牱涓€涓簲鐢ㄧ▼搴忥紝瀹冨悓鎰忚姹傜鐨勮繛鎺ワ紝骞跺彂閫佸搷搴旓紙response锛夈€備换浣曠粰瀹氱殑绋嬪簭閮芥湁鍙兘鏃㈠仛瀹㈡埛绔張鍋氭湇鍔″櫒锛涙垜浠娇鐢ㄨ繖浜涙湳璇槸涓轰簡璇存槑鐗瑰畾杩炴帴涓簲鐢ㄧ▼搴忔墍鎷呭綋鐨勮鑹诧紝鑰屼笉鏄寚閫氬父鎰忎箟涓婂簲鐢ㄧ▼搴忕殑鑳藉姏銆傚悓鏍凤紝浠讳綍鏈嶅姟鍣ㄩ兘鍙互鍩轰簬姣忎釜璇锋眰鐨勬€ц川鎵紨婧愭湇鍔″櫒锛屼唬鐞嗭紝缃戝叧锛屾垨鑰呴毀閬撶瓑瑙掕壊涔嬩竴銆?/p>
婧愭湇鍔″櫒锛圤rigin server锛?/p>
瀛樺湪璧勬簮鎴栬€呰祫婧愬湪鍏朵笂琚垱寤虹殑鏈嶅姟鍣紙server锛夎鎴愪负婧愭湇鍔″櫒锛坥rigin server锛夈€?nbsp;
浠g悊锛?Proxy锛?/p>
浠g悊鏄竴涓腑闂寸▼搴忥紝瀹冩棦鎷呭綋瀹㈡埛绔殑瑙掕壊涔熸媴褰撴湇鍔″櫒鐨勮鑹层€備唬鐞嗕唬琛ㄥ鎴风鍚戞湇鍔″櫒鍙戦€佽姹傘€傚鎴风鐨勮姹傜粡杩囦唬鐞嗭紝浼氬湪浠g悊鍐呴儴寰楀埌鏈嶅姟鎴栬€呯粡杩囦竴瀹氱殑杞崲杞嚦鍏朵粬鏈嶅姟鍣ㄣ€備竴涓唬鐞嗗繀椤昏兘鍚屾椂瀹炵幇鏈鑼冧腑瀵瑰鎴风鍜屾湇鍔″櫒鎵€浣滅殑瑕佹眰銆傞€忔槑浠g悊锛坱ransparent proxy锛夐渶瑕佷唬鐞嗘巿鏉冨拰浠g悊璇嗗埆锛屼絾涓嶄慨鏀硅姹傛垨鍝嶅簲銆傞潪閫忔槑浠g悊锛坣on-transparent proxy锛夐渶淇敼璇锋眰鎴栧搷搴旓紝浠ヤ究涓虹敤鎴蜂唬鐞嗭紙user agent锛夋彁渚涢檮鍔犳湇鍔★紝闄勫姞鏈嶅姟鍖呮嫭缁勬敞閲婃湇鍔★紝濯掍綋绫诲瀷杞崲锛屽崗璁畝鍖栵紝鎴栬€呭尶鍚嶈繃婊ょ瓑銆傞櫎闈為€忔槑琛屼负鎴栭潪閫忔槑琛屼负缁忔槑纭寚鍑猴紝鍚﹀垯锛孒TTP浠g悊鏃㈡槸閫忔槑浠g悊涔熸槸闈為€忔槑浠g悊銆?/p>
缃戝叧锛坓ateway锛?/p>
缃戝叧鍏跺疄鏄竴涓湇鍔″櫒锛屾壆婕旂潃浠h〃鍏跺畠鏈嶅姟鍣ㄤ负瀹㈡埛绔彁渚涙湇鍔$殑涓棿鑰呫€備笌浠g悊锛坧roxy锛変笉鍚岋紝缃戝叧鎺ユ敹璇锋眰锛屼豢浣涘畠灏辨槸璇锋眰璧勬簮鐨勬簮鏈嶅姟鍣ㄣ€傝姹傜殑瀹㈡埛绔彲鑳借瀵熶笉鍒板畠姝e湪鍚岀綉鍏抽€氫俊銆?/p>
闅ч亾锛坱unnel锛?/p>
闅ч亾涔熸槸涓€涓腑闂寸▼搴忥紝瀹冧竴涓湪涓や釜杩炴帴涔嬮棿鍏呭綋鐩茬洰涓户锛坆lind relay锛夌殑涓棿绋嬪簭銆備竴鏃﹂毀閬撳浜庢椿鍔ㄧ姸鎬侊紝瀹冧笉鑳借璁や负鏄繖娆TTP閫氫俊鐨勫弬涓庤€咃紝铏界劧HTTP璇锋眰鍙兘宸茬粡鎶婂畠鍒濆鍖栦簡銆傚綋涓ょ鐨勪腑缁ц繛鎺ラ兘鍏抽棴鐨勬椂鍊欙紝闅ч亾涓嶅啀瀛樺湪銆?/p>
缂撳瓨锛坈ache锛?/p>
缂撳瓨鏄▼搴忓搷搴旀秷鎭殑鏈湴瀛樺偍銆傜紦瀛樻槸涓€涓瓙绯荤粺锛屾帶鍒舵秷鎭殑瀛樺偍銆佸彇鍥炲拰鍒犻櫎銆傜紦瀛橀噷瀛樻斁鍙紦瀛樺搷搴旓紙cacheable response锛変负鐨勬槸鍑忓皯瀵瑰皢鏉ュ悓鏍疯姹傜殑鍝嶅簲鏃堕棿鍜岀綉缁滃甫瀹芥秷鑰椼€備换涓€瀹㈡埛绔垨鏈嶅姟鍣ㄩ兘鍙兘鍚湁缂撳瓨锛屼絾楂橀€熺紦瀛樹笉鑳借涓€涓厖褰撻毀閬擄紙tunnel锛夌殑鏈嶅姟鍣ㄤ娇鐢ㄣ€?/p>
鍙紦瀛橈紙cacheable锛?/p>
鎴戜滑鍙互璇村搷搴旓紙response锛夋槸鍙紦瀛樼殑锛屽鏋滀竴涓紦瀛橈紙cache锛変负浜嗗搷搴斿悗缁ц姹傝€岃鍏佽瀛樺偍鍝嶅簲娑堟伅锛坮esponse message锛夌殑鍓湰銆傜‘瀹欻TTP鍝嶅簲鐨勭紦瀛樿兘鍔涳紙cacheability锛夊湪13鑺備腑鏈変粙缁嶃€傚嵆浣夸竴涓祫婧愶紙resourse锛夋槸鍙紦瀛樼殑锛屼篃鍙兘瀛樺湪缂撳瓨鏄惁鑳藉埄鐢ㄧ紦瀛樺壇鏈殑绾︽潫銆?/p>
绗竴鎵嬬殑锛坒irst-hand锛?/p>
濡傛灉涓€涓搷搴旂洿鎺ヤ粠婧愭湇鍔″櫒鎴栫粡杩囪嫢骞蹭唬鐞嗭紙proxy锛夛紝骞朵笖娌℃湁涓嶅繀瑕佺殑寤舵椂锛屾渶鍚庡埌杈惧鎴风锛岄偅涔堣繖涓搷搴斿氨鏄涓€鎵嬬殑锛坒irst-hand锛夈€?/p>
濡傛灉鍝嶅簲琚簮鏈嶅姟鍣紙origin server锛夐獙璇佹槸鏈夋晥鎬э紙validity锛夌殑锛岄偅涔堣繖涓搷搴斾篃鍚屾牱鏄涓€鎵嬬殑銆?/p>
鏄庣‘杩囨湡鏃堕棿锛坋xplicit expiration time锛?nbsp;
鏄簮鏈嶅姟鍣ㄥ笇鏈涘疄浣擄紙entity锛夊鏋滄病鏈夎杩涗竴姝ラ獙璇侊紙validation锛夊氨涓嶈鍐嶈缂撳瓨锛坈ache锛夎繑鍥炵殑鏃堕棿銆?/p>
鍚彂寮忚繃鏈熸椂闂达紙heuristic expiration time锛?nbsp;
褰撴病鏈夋槑纭粓姝㈡椂闂达紙explicit expiration time锛夊彲鍒╃敤鏃讹紝鐢辩紦瀛樻墍鎸囧畾鐨勭粓姝㈡椂闂?
骞撮緞锛坅ge锛?/p>
涓€涓搷搴旂殑骞撮緞鏄粠琚簮鏈嶅姟鍣ㄥ彂閫佹垨琚簮鏈嶅姟鍣ㄦ垚鍔熺‘璁ょ殑鏃堕棿鐐瑰埌鐜板湪鐨勬椂闂淬€?/p>
淇濋矞瀵垮懡锛坒reshness lifetime锛?/p>
涓€涓搷搴斾骇鐢熺殑鏃堕棿鐐瑰埌杩囨湡鏃堕棿鐐逛箣闂寸殑闀垮害銆?/p>
淇濋矞锛團resh锛?nbsp;
濡傛灉涓€涓搷搴旂殑骞撮緞杩樻病鏈夎秴杩囦繚椴滃鍛斤紙freshness lifetime锛夛紝瀹冨氨鏄繚椴滅殑.
闄堟棫锛圫tale锛?/p>
涓€涓搷搴旂殑骞撮緞宸茬粡瓒呰繃浜嗗畠鐨勪繚椴滃鍛斤紙freshness lifetime锛夛紝灏辨槸闄堟棫鐨?
璇箟閫忔槑锛坰emantically transparent锛?/p>
缂撳瓨锛坈ache锛夊彲鑳戒細浠ヤ竴绉嶈鎰忛€忔槑锛坰emantically transparent锛夌殑鏂瑰紡宸ヤ綔銆傝繖鏃讹紝瀵逛簬涓€涓壒瀹氱殑鍝嶅簲锛屼娇鐢ㄧ紦瀛樻棦涓嶄細瀵硅姹傚鎴风浜х敓褰卞搷涔熶笉浼氬婧愭湇鍔″櫒浜х敓褰卞搷锛岀紦瀛樼殑浣跨敤鍙槸涓轰簡鎻愰珮鎬ц兘銆傚綋缂撳瓨锛坈ache锛夊叿鏈夎鎰忛€忔槑鎬ф椂锛屽鎴风浠庣紦瀛樻帴鏀剁殑鍝嶅簲璺熺洿鎺ヤ粠婧愭湇鍔″櫒鎺ユ敹鐨勫搷搴斿畬鍏ㄤ竴鑷达紙闄や簡浣跨敤hop-by-hop澶村煙锛夈€?/p>
楠岃瘉鍣紙Validator锛?/p>
楠岃瘉鍣ㄥ叾瀹炴槸鍗忚鍏冪礌锛堜緥濡傦細瀹炰綋澶达紙entity tag锛夋垨鏈€鍚庢洿鏀规椂闂达紙last-modified time锛夌瓑锛夛紝杩欎簺鍗忚鍏冪礌琚敤浜庤瘑鍒紦瀛橀噷淇濆瓨鐨勬暟鎹紙鍗崇紦瀛橀」锛夋槸鍚︽槸婧愭湇鍔″櫒鐨勫疄浣撶殑鍓湰銆?/p>
涓婃父/涓嬫父锛坲pstream/downstream锛?/p>
涓婃父鍜屼笅娓告弿杩颁簡娑堟伅鐨勬祦鍔?鎵€鏈夋秷鎭兘浠庝笂娓告祦鍒颁笅娓?
鍚戝唴/鍚戝锛坕nbound/outbound锛?/p>
鍚戝唴鍜屽悜澶栨寚鐨勬槸娑堟伅鐨勮姹傚拰鍝嶅簲璺緞:"鍚戝唴"鍗?绉诲悜婧愭湇鍔″櫒","鍚戝"鍗?绉诲悜鐢ㄦ埛浠g悊锛坲ser agent锛?.
1.4 鎬讳綋鎿嶄綔
HTTP鍗忚鏄竴绉嶈姹?鍝嶅簲鍗忚銆?涓庢湇鍔″櫒寤虹珛杩炴帴鍚庯紝瀹㈡埛绔互璇锋眰鏂规硶锛孶RI鍜屽崗璁増鏈彿锛岀劧鍚庣揣鎺ョ潃璺熼殢涓€涓被MIME锛圡IME-like锛夋秷鎭紝杩欎釜绫籑IME娑堟伅鍖呮嫭璇锋眰淇グ绗︼紝瀹㈡埛淇℃伅鍜屽彲鑳界殑娑堟伅涓讳綋銆傛湇鍔″櫒浠ヤ竴涓姸鎬佽骞惰窡闅忎竴涓被MIME锛圡IME-like锛夋秷鎭搷搴旓紝鐘舵€佽鍖呭惈娑堟伅鐨勫崗璁増鏈拰鎴愬姛鍑洪敊鐨勭姸鎬佺爜锛岀被MIME娑堟伅鍖呭惈鏈嶅姟鍣ㄤ俊鎭紝瀹炰綋鍏冧俊鎭紝鍜屽彲鑳界殑瀹炰綋銆侶TTP鍜孧IME涔嬮棿鐨勫叧绯诲闄勫綍19.4鑺傛墍闃愯堪銆?/p>
澶ч儴鍒嗙殑HTTP閫氫俊鏄敱鐢ㄦ埛浠g悊锛坲ser agent锛夊紑濮嬬殑锛岀敱搴旂敤鍒颁竴涓渶瑕佹簮鏈嶅姟鍣ㄨ祫婧愮殑璇锋眰鏋勬垚銆傛渶绠€鍗曠殑鎯呭舰锛屽彲浠ョ粡鐢ㄦ埛浠g悊锛圲A锛夊拰婧愭湇鍔″櫒锛圤锛変箣闂寸殑鍗曚竴杩炴帴锛坴锛夊畬鎴愩€?/p>
璇锋眰閾撅紙Request chain锛?-------------------- ----------à
鐢ㄦ埛浠g悊锛圲A锛?---------------鍗曚竴杩炴帴锛坴锛?-------------婧愭湇鍔″櫒锛圤锛?/p>
<---------------------------------------鍝嶅簲閾撅紙response chain锛?/p>
褰撲竴涓垨澶氫釜涓棿鑰呭湪璇锋眰/鍝嶅簲閾句腑鍑虹幇鐨勬椂鍊欙紝浼氬嚭鐜版洿澶嶆潅鐨勬儏褰€傚父瑙佺殑涓棿鑰呮湁涓夌锛氫唬鐞嗭紙proxy锛夛紝缃戝叧锛坓ateway锛夊拰闅ч亾锛坱unnel锛夈€備唬鐞嗭紙proxy锛夋槸涓€绉嶈浆鍙戜唬鐞嗭紙a forwarding agent锛夛紝瀹冩帴鏀剁粷瀵筓RI锛坅bsoulute url锛岀浉瀵逛簬鐩稿url锛夎姹傦紝閲嶅啓鍏ㄩ儴鎴栭儴鍒嗘秷鎭紝鐒跺悗鎶婃牸寮忓寲鍚庣殑璇锋眰鍙戦€佸埌URI鎸囧畾鐨勬湇鍔″櫒涓娿€傜綉鍏虫槸涓€绉嶆帴鏀朵唬鐞嗭紙receiving agent锛夛紝瀹冨厖褰撲竴涓眰锛坙ayer锛夛紝杩欎釜灞傚湪鏈嶅姟鍣ㄤ箣涓婏紝蹇呰鏃跺畠浼氭妸璇锋眰缈昏瘧鎴愪负涓嬪眰鏈嶅姟鍣ㄧ殑鍗忚銆傞毀閬撲笉鏀瑰彉娑堟伅鑰屽厖褰撲袱涓繛鎺ヤ箣闂寸殑涓户鐐癸紱瀹冪敤浜庨€氫俊闇€瑕佺┛杩囦腑闂磋€咃紙濡傞槻鐏锛夌敋鑷冲綋涓棿鑰呬笉鑳界悊瑙f秷鎭唴瀹圭殑鏃跺€欍€?/p>
璇锋眰閾撅紙request chain锛?---------------------------------------à
UA-----v-----A-----v-----B-----v-----C------------v-----------------O
<----------------------------------------鍝嶅簲閾撅紙response chain锛?/p>
涓婂浘鏄剧ず浜嗙敤鎴蜂唬鐞嗭紙user agent锛夊拰婧愭湇鍔″櫒涔嬮棿鐨勪笁涓腑闂磋€咃紙A锛孊鍜孋锛夈€傛暣鏉¢摼鐨勮姹傛垨鍝嶅簲灏嗕細閫氳繃鍥涗釜鍗曠嫭鐨勮繛鎺ャ€傝繖涓壒鎬у緢閲嶈锛屽洜涓烘煇浜汬TTP閫氫俊閫夐」鍙兘鍙兘搴旂敤浜庝笌鏈€杩戠殑闈為毀閬撻偦鎺ョ偣鐨勮繛鎺ワ紝鍙兘搴旂敤浜庨摼鐨勭鐐癸紙end-point锛夌殑杩炴帴锛屾垨鑰呰兘搴旂敤浜庢閾剧殑鎵€鏈夎繛鎺ャ€傚浘琛ㄥ敖绠℃槸绾挎€х殑锛屾瘡涓弬涓庤€呭彲鑳藉繖浜庡璺悓鏃堕€氫俊銆備緥濡傦紝B鍙互鎺ユ敹鏉ヨ嚜涓嶅悓浜嶢鐨勮澶氬鎴风殑璇锋眰锛屽苟涓旓紡鎴栬€呭彲浠ユ妸璇锋眰杞埌涓嶅悓浜嶤鐨勬湇鍔″櫒锛屼笌姝ゅ悓鏃讹紝瀹冭繕鍦ㄥ鐞咥鐨勮姹傘€?/p>
浠讳綍闈為毀閬撶殑閫氫俊鎴愬憳閮藉彲鑳戒細閲囩敤涓€涓唴閮ㄧ紦瀛橈紙cache锛夋潵澶勭悊璇锋眰銆傚鏋滄部鐫€閾剧殑閫氫俊鎴愬憳瀵硅姹傞噰鐢ㄤ簡缂撳瓨鍝嶅簲锛岃姹?鍝嶅簲閾惧氨浼氬ぇ澶х缉鐭€備笅鍥鹃槓鏄庝簡涓€涓渶缁堣姹傚搷搴旈摼锛岃繖鏄湪鍋囧畾B鎷ユ湁涓€涓潵鑷狾锛堥€氳繃C锛夌殑浠ュ墠璇锋眰鐨勫搷搴斿壇鏈紝浣嗘鍝嶅簲灏氭湭琚玌A鎴朅缂撳瓨銆?/p>
璇锋眰閾撅紙request chain锛?--------->
UA-----v----------A-----v-----B-----C----O
<---------鍝嶅簲閾?锛坮esponse chain锛?/p>
骞朵笉鏄墍鏈夌殑鍝嶅簲閮借兘鏈夋晥鍦扮紦瀛橈紝涓€浜涜姹傚彲鑳藉惈鏈変慨楗扮锛岃繖浜涗慨楗扮瀵圭紦瀛樺姩浣滄湁鐗规畩鐨勮姹傘€傜紦瀛樺姩浣滃拰缂撳瓨鍝嶅簲鐨凥TTP琛屼负瑕佹眰灏嗗湪绗?3鑺傚畾涔夈€?/p>
瀹為檯涓婏紝鐩墠涓囩淮缃戜笂鏈夊绉嶇粨鏋勫拰閰嶇疆鐨勭紦瀛橈紙cache锛夊拰浠g悊锛坧roxy锛夋鍦ㄨ浣跨敤銆傝繖浜涚郴缁熷寘鎷妭鐪佸甫瀹界殑缂撳瓨浠g悊锛坧roxy cache锛夛紝鍙互骞挎挱鎴栧鐐逛紶閫佺紦瀛樻暟鎹殑绯荤粺锛岄€氳繃CD-ROM鍒嗛厤缂撳瓨鏁版嵁瀛愰泦鐨勬満鏋勶紝绛夌瓑銆侶TTP绯荤粺锛坔ttp system锛変細琚簲鐢ㄤ簬瀹藉甫杩炴帴鐨勪紒涓氬眬鍩熺綉涓殑鍗忎綔锛屽苟涓斿彲浠ラ€氳繃PDA杩涜浣庤€楁棤绾跨殑锛屾柇缁繛鎺ョ殑璁块棶銆侶TTP1.1鐨勫畻鏃ㄦ槸涓轰簡鏀寔鍚勭鍚勬牱鐨勫凡缁忛儴缃茬殑閰嶇疆锛屽悓鏃跺紩杩涗竴绉嶅崗璁粨鏋勶紝璁╁畠婊¤冻閭d簺闇€瑕佽緝楂樺彲闈犳€э紝鍗充娇涓嶈兘杈惧埌杈冮珮鍙潬鎬х殑瑕佹眰锛屼篃瑕佷篃璁╁畠鑷冲皯鍙互鎸囩ず鏁呴殰鐨勭綉缁滃簲鐢ㄧ殑瑕佹眰銆?/p>
HTTP閫氫俊閫氬父鍙戠敓鍦═CP/IP杩炴帴涓娿€傞粯璁ょ鍙f槸TCP 80锛屼笉杩囧叾瀹冪鍙d篃鍙互浣跨敤銆傝繖骞朵笉濡ㄧHTTP鐨勫疄鐜拌搴旂敤浜庝簰鑱旂綉锛坕nternt锛夋垨鍏跺畠缃戠殑鍗忚涔嬩笂銆侶ttp浠呬粎鏈熸湜鐨勬槸涓€涓彲闈犵殑浼犺緭锛堣瘧娉細HTTP涓€鑸缓绔嬪湪浼犺緭灞傚崗璁箣涓婏級锛涗换浣曟彁渚涜繖绉嶄繚璇佺殑鍗忚閮藉彲浠ヨ浣跨敤锛涘崗璁紶杈撴暟鎹崟鍏冿紙transport data unit锛変笌HTTP/1.1璇锋眰鍜屽搷搴旂殑娑堟伅缁撴瀯涔嬮棿鐨勬槧璞″凡缁忚秴鍑轰簡鏈鏄庝功鐨勮寖鍥淬€?/p>
澶ч儴鍒咹TTP/1.0鐨勫疄鐜伴兘鏄拡瀵规瘡涓姹?鍝嶅簲浜ゆ崲浜х敓涓€涓柊鐨勮繛鎺ャ€傝€宧ttp/1.1涓紝涓€涓繛鎺ュ彲浠ヨ鐢ㄤ簬涓€涓垨鏇村璇锋眰/鍝嶅簲浜ゆ崲锛岃櫧鐒惰繛鎺ュ彲鑳戒細鍥犱负鍚勭鍘熷洜涓柇锛堣绗?.1鑺傦級銆?/p>
2 绗﹀彿涔犳儻鍜屼竴鑸娉?nbsp;
2.1 鎵╁厖鐨凚NF锛堟墿鍏呯殑 宸寸鏂?璇哄皵鑼冨紡锛?br />鏈枃妗h瀹氱殑鎵€鏈夋満鍒堕兘鐢ㄤ袱绉嶆柟娉曟弿杩帮細鏁f枃浣擄紙prose锛夊拰绫讳技浜嶳FC 822鐨勬墿鍏匓ackus-Naur Form锛圔NF锛夈€傝鐞嗚В鏈鑼冿紝浣跨敤鑰呴渶鐔熸倝绗﹀彿琛ㄧず娉曘€傛墿鍏匓NF缁撴瀯濡備笅锛?/p>
鍚嶅瓧锛坣ame锛?瀹氫箟锛坉efinition锛?/p>
鍚嶅瓧锛坣ame锛夊氨鏄唬琛ㄨ鍒欑殑鍚嶅瓧锛堣瘧娉細濡傦細CRLF锛孌IGIT绛夌瓑閮芥槸瑙勫垯鍚嶏級锛岃鍒欏悕閲屼笉鑳藉寘鍚?ldquo;<”鍜?ldquo;>”锛岄€氳繃绛変簬鍙锋妸瑙勫垯鍚嶅拰瑙勫垯瀹氫箟锛坉efiniation锛夊垎绂诲紑銆傜┖鐧斤紙white space锛夋槸鏈夋剰涔夌殑锛屽洜涓哄彲浠ョ敤缂╄繘锛坕ndentation锛岃瘧娉細缂╄繘灏辨槸绌虹櫧锛屽悗闈細璁插埌LWS锛?鎶婅鍒欏畾涔夋樉绀烘垚澶氳銆傛煇浜涘熀鏈鍒欙紙basic rule锛岃瘧娉細2.2鑺傝鏄庡熀鏈鍒欑殑璇硶锛変娇鐢ㄥぇ鍐欏瓧姣嶅寘鍚湪瑙勫垯瀹氫箟閲岋紝 浣犲SP锛孡WS锛孒T锛孋RLF锛孌IGIT锛孉LPHA锛岀瓑绛夈€傚皷鎷彿鍙互鍖呭惈鍦ㄨ鍒欏畾涔夐噷锛屽彧瑕佸畠浠殑瀛樺湪鏈夊埄浜庤瘑鍒鍒欏悕锛堣瘧娉細LWS锛孒T绛夐兘鏄鍒欏悕锛夈€?/p>
“瀛楅潰鏂囨湰”锛?ldquo;literal”锛?/p>
瀛楅潰鏂囨湰锛坙iteral text锛変袱杈圭敤寮曞彿銆傞櫎闈炲0鏄庯紝瀛楅潰鏂囨湰澶у皬鍐欎笉鏁忔劅锛堣瘧娉細濡傦紝HEX = "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f" | DIGIT 閲岀殑A锛孊,C锛孌绛夌瓑閮芥槸瀛楅潰鏂囨湰锛坙iteral text锛夛級銆?/p>
瑙勫垯1 | 瑙勫垯2
鐢辩珫绾匡紙“|”锛夊垎寮€鐨勫厓绱犳槸鍙€夌殑锛屼緥濡傦紝“yes | no”琛ㄧずyes鎴杗o閮芥槸鍙帴鍙楃殑銆?/p>
锛堣鍒? 瑙勫垯2锛?/p>
鍥村湪鎷彿閲岀殑澶氫釜鍏冪礌瑙嗕綔涓€涓厓绱犮€傛墍浠ワ紝“锛坋lem 锛坒oo | bar锛?elem锛?rdquo;鐨勭鍚堢殑瀛楃涓叉槸“elem foo elem”鍜?ldquo;elem bar elem”銆?/p>
*瑙勫垯
鍓嶉潰鐨勫瓧绗?ldquo;*”琛ㄧず閲嶅銆傚畬鏁寸殑褰㈠紡鏄?ldquo;<n>*<m>鍏冪礌”锛岃〃绀哄厓绱犺嚦灏戝嚭鐜?lt;n>娆★紝鑷冲鍑虹幇<m>娆°€傞粯璁ゅ€兼槸0鍜屾棤绌峰ぇ锛屾墍浠?*锛堝厓绱狅級"鍏佽浠讳綍鏁板€硷紝鍖呮嫭闆讹紱"1*鍏冪礌"鑷冲皯闇€瑕佷竴娆★紱"1*2element"鍏佽涓€娆℃垨涓ゆ銆?/p>
[瑙勫垯]
鏂规嫭鍙烽噷鏄换閫夊厓绱狅紱“[foo bar]”鐩稿綋浜?ldquo;*1锛坒oo bar锛?rdquo;銆?/p>
N 瑙勫垯
鐗规畩鐨勯噸澶嶏細“<n>锛堝厓绱狅級”涓?ldquo;<n>*<n>锛堝厓绱狅級”绛変环锛涘氨鏄锛岋紙鍏冪礌锛夋濂藉嚭鐜颁簡<n>娆°€傝繖鏍?DIGIT鏄竴涓袱浣嶆暟瀛楋紝3ALPHA鏄竴涓敱涓変釜瀛楃缁勬垚鐨勫瓧绗︿覆銆?/p>
#瑙勫垯
绫讳技浜?ldquo;*”锛岀粨鏋?ldquo;#”鏄敤鏉ュ畾涔変竴绯诲垪鍏冪礌鐨勩€傚畬鏁寸殑褰㈠紡鏄?lt;n>#<m>鍏冪礌锛岃〃绀鸿嚦灏?lt;n>涓厓绱狅紝鑷冲<m>涓厓绱狅紝鍏冪礌涔嬮棿琚竴涓垨澶氫釜閫楀彿锛?ldquo;,”锛変互鍙婂彲閫夌殑绾挎€х┖鐧斤紙LWS锛夐殧寮€浜嗐€傝繖灏变娇寰楄〃绀哄垪琛ㄨ繖鏍风殑褰㈠紡鍙樺緱闈炲父瀹规槗锛涘儚
锛?*LWS element锛?*锛?*LWS ","*LWS element 锛夛級
灏卞彲浠ヨ〃绀轰负
1#element
鏃犺鍦ㄥ摢閲屼娇鐢ㄨ繖涓粨鏋勶紝绌哄厓绱犻兘鏄厑璁哥殑锛屼絾鏄笉璁″叆鍏冪礌鍑虹幇鐨勬鏁般€傛崲鍙ヨ瘽璇?锛?/p>
“锛坋lement 锛? , 锛坋lement锛?nbsp; ”鏄厑璁哥殑锛屼絾鏄粎浠呰涓轰袱涓厓绱犮€傚洜姝わ紝鍦ㄨ嚦灏戦渶瑕佷竴涓厓绱犵殑鍦版柟锛屽繀椤诲瓨鍦ㄨ嚦灏戜竴涓潪绌哄厓绱犮€傞粯璁ゅ€兼槸0鍜屾棤绌峰ぇ锛岃繖鏍凤紝“#element”鍏佽浠绘剰闆朵釜鎴栧涓厓绱狅紱“1# element”闇€瑕佽嚦灏戜竴涓紱“1#2element”鍏佽涓€涓垨涓や釜鍏冪礌銆?/p>
锛涙敞閲婏紙comment锛?/p>
鐢ㄥ垎鍙峰紩瀵兼敞閲娿€?/p>
闅愬惈鐨勶紙implied锛?*LWS
鏈鏄庝功鎵€鎻忚堪鐨勮娉曟槸鍩轰簬瀛楃殑銆傞櫎闈炵壒鍒敞鏄庯紝绾挎€х┖鐧藉彲鍑虹幇鍦ㄤ换浣曚袱涓浉閭诲瓧涔嬮棿锛堟爣璁帮紙token锛夋垨寮曠敤瀛楃涓诧紙quoted-string锛夛級锛屼互鍙婄浉閭诲瓧鍜岄棿闅旂涔嬮棿锛岃繖骞舵病鏈夋敼鍙樹竴涓煙鐨勮В閲娿€備换浣曚袱涓爣璁帮紙token锛変箣闂村繀椤绘湁鑷冲皯涓€涓垎鍓茬锛屽惁鍒欏皢浼氳鐞嗚В涓哄崟涓€鏍囪銆?/p>
2.2鍩烘湰瑙勫垯 锛坆asic rule锛?br />涓嬮潰鐨勮鍒欒疮绌夸簬鏈鑼冪殑鍏ㄦ枃锛屾瑙勫垯鎻忚堪浜嗗熀鏈殑瑙f瀽缁撴瀯銆俇S-ASCII锛堢編鍥戒俊鎭氦鎹㈡爣鍑嗙爜锛夌紪鐮佸瓧绗﹂泦鏄敱ANSI X3.4-1986[21]瀹氫箟鐨勩€?/p>
OCTET锛堝瓧鑺傦級 = <浠绘剰鍏瘮鐗圭殑鏁版嵁搴忓垪>
CHAR = <浠绘剰ASCII瀛楃锛坅scii鐮佸€间粠 0鍒?27鐨勫瓧鑺傦級>
UPALPHA = <浠绘剰澶у啓瀛楁瘝"A"..."Z">
LOALPHA = <浠绘剰灏忓啓瀛楁瘝"a"..."z">
ALPHA = UPALPHA | LOALPHA
DIGIT = <浠绘剰鏁板瓧0锛?锛?..9>
CTL = <浠绘剰鎺у埗瀛楃锛坅scii鐮佸€间粠0 鍒?31鐨勫瓧鑺傦級鍙婂垹闄ら敭DEL锛?27>
CR = <US-ASCII CR, 鍥炶溅锛?3锛?gt;
LF = <US-ASCII LF, 鎹㈣绗︼紙10锛?gt;
SP = <US-ASCII SP, 绌烘牸锛?2锛?gt;
HT = <US-ASCII HT, 姘村钩鍒惰〃 锛?锛?gt;
<"> = <US-ASCII 鍙屽紩鍙凤紙34锛?gt;
HTTP/1.1灏?CR LF 鐨勫簭鍒楀畾涔変负浠讳綍鍗忚鍏冪礌鐨勮灏炬爣蹇楋紝浣嗚繖闄や簡瀹炰綋涓讳綋锛坋ndtity-body锛夊锛堣姹傛瘮杈冩澗鐨勫簲鐢ㄨ闄勫綍19.3锛夈€傚疄浣撲富浣擄紙entity-body锛夌殑琛屽熬鏍囧織鏄敱瀹冪殑鍏宠仈濯掍綋绫诲瀷瀹氫箟鐨勶紝濡?.7鑺傛墍杩般€?/p>
CRLF = CR LF
HTTP/1.1 鐨勬秷鎭ご鍩熷€煎彲浠ユ姌鍙犳垚澶氳锛屼絾绱ф帴鐫€鐨勬姌鍙犺鐢辩┖鏍硷紙SP锛夋垨姘村钩鍒惰〃锛圚T锛夋姌鍙犳爣璁板紑濮嬨€傛墍鏈夌殑绾挎€х┖鐧斤紙LWS锛夊寘鎷姌鍙犺鐨勬姌鍙犳爣璁帮紙绌烘牸SP鎴栨按骞冲埗琛ㄩ敭HT锛夛紝鍏锋湁鍚孲P涓€鏍风殑璇箟銆傛帴鏀惰€呭湪瑙f瀽鍩熷€兼垨灏嗘秷鎭浆閫佸埌涓嬫父锛坉ownstream锛変箣鍓嶅彲鑳戒細灏嗕换浣曠嚎鎬х┖鐧斤紙LWS锛夋浛鎹㈡垚鍗曚釜SP锛堢┖鏍硷級銆?/p>
LWS = [CRLF] 1*锛?SP | HT 锛?/p>
涓嬮潰鐨凾EXT瑙勫垯浠呬粎閫傜敤浜庡煙鍐呭鍜屽煙鍊肩殑鎻忚堪锛屼笉浼氳娑堟伅瑙i噴鍣ㄨВ鏋愩€俆EXT閲岀殑瀛楀彲浠ュ寘鍚笉浠呬粎鏄疘SO-8859-1[22]閲岀殑瀛楃闆嗭紝涔熷彲浠ュ寘鍚玆FC 2047閲岃瀹氱殑瀛楃闆嗐€?/p>
TEXT = <闄TLs浠ュ鐨勪换鎰廜CTET锛屼絾鍖呮嫭LWS>
涓€涓狢RLF鍙湁浣滀负HTTP娑堟伅澶村煙寤剁画鐨勪竴閮ㄥ垎鏃舵墠鍦═EXT瀹氫箟閲屼娇鐢ㄣ€?/p>
鍗佸叚杩涘埗鏁板瓧瀛楃鐢ㄥ湪澶氫釜鍗忚鍏冪礌锛坧rotocol element锛夐噷銆?/p>
HEX = "A" | "B" | "C" | "D" | "E" | "F"
| "a" | "b" | "c" | "d" | "e" | "f" | DIGIT
璁稿HTTP/1.1鐨勬秷鎭ご鍩熷€兼槸鐢盠WS鎴栫壒娈婂瓧绗﹀垎闅旂殑瀛楁瀯鎴愮殑銆傝繖浜涚壒娈婂瓧绗﹀繀椤诲厛琚寘鍚湪寮曠敤瀛楃涓诧紙quoted string锛夐噷涔嬪悗鎵嶈兘鐢ㄤ簬鍙傛暟鍊硷紙濡?.6鑺傚畾涔夛級閲屻€?/p>
token 锛堟爣璁帮級 = 1*<闄TLs涓庡垎鍓茬浠ュ鐨勪换鎰?CHAR >
separators锛堝垎鍓茬锛?nbsp; = "锛? | "锛? | "<" | ">" | "@"
| "," | ";" | ":" | """ | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
閫氳繃鐢ㄥ渾鎷彿鎷捣鏉ワ紝娉ㄩ噴锛坈omment锛夊彲浠ュ寘鍚湪涓€浜汬TTP澶村煙閲屻€傛敞閲婂彧鍙互浣滀负鍩熷畾涔夌殑涓€閮ㄥ垎銆傚湪鍏朵粬鍩熼噷锛屽渾鎷彿琚浣滃煙鍊肩殑涓€閮ㄥ垎銆?/p>
comment 锛堟敞閲婏級= "锛? *锛?ctext | quoted-pair | comment 锛?"锛?
ctext = <闄?锛? 鍜?"锛?浠ュ鐨勪换鎰廡EXT >
濡傛灉涓€涓猅EXT鑻ヨ鍖呭惈鍦ㄥ弻寮曞彿閲岋紝鍒欏綋浣滀竴涓瓧銆?/p>
quoted-string = 锛?<"> *锛坬dtext | quoted-pair 锛?<"> 锛?/p>
qdtext = <any TEXT except <">>
鏂滃垝绾匡紙"""锛夊彲浠ヨ浣滀负鍗曚釜瀛楃鐨勫紩鐢ㄦ満鍒讹紝浣嗘槸蹇呴』瑕佸湪寮曞彿鍜屾敞閲婂尯涔嬪唴銆?/p>
quoted-pair = """ CHAR
3 鍗忚鍙傛暟
3.1 HTTP鐗堟湰
HTTP浣跨敤涓€涓?ldquo;<major>.<minor>”鏁板瓧妯″紡鏉ユ寚鏄庡崗璁殑鐗堟湰鍙枫€傚崗璁殑鐗堟湰鍙锋槸涓轰簡璁╁彂閫佺鎸囨槑娑堟伅鐨勬牸寮忓拰瀹冪殑鑳藉姏锛岃繖鏄负浜嗚繘涓€姝ョ殑HTTP閫氫俊锛岃€屼笉浠呬粎鏄幏寰楅€氫俊鐨勭壒寰併€傚崗璁増鏈槸涓嶉渶瑕佷慨鏀圭殑锛屽綋娑堟伅缁勪欢鐨勫鍔犱笉浼氬奖鍝嶉€氫俊琛屼负鎴栫潃鍙鍔犱簡鎵╁睍鐨勫煙鍊笺€?lt;minor>鏁板瓧鏄€掑鐨勶紝褰撳崗璁細鍥犱负娣诲姞涓€浜涚壒寰佽€屽仛浜嗕慨鏀圭殑鏃跺€欍€備絾杩欎簺鍙樺寲涓嶄細褰卞搷閫氬父鐨勬秷鎭В鏋愮畻娉曪紝浣嗘槸瀹冧細缁欐秷鎭坊鍔犺鎰忥紙semantic锛夊苟涓斾細鏆楃ず鍙戦€佽€呭叿鏈夐澶栫殑鑳藉姏銆?lt;major>鏁板瓧涔熸槸涓嶆柇閫掑鐨勶紝褰撳崗璁殑娑堟伅鏍煎紡姣忔鍙戠敓鍙樺寲鏃躲€?/p>
HTTP娑堟伅鐨勭増鏈湪HTTP-Version鍩熻鎸囨槑锛孒TTP-Version鍩熷湪娑堟伅鐨勭涓€琛屼腑銆?/p>
HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
娉ㄦ剰major鍜宮inor鏁板瓧蹇呴』琚湅鎴愪袱涓嫭绔嬫暣鏁帮紝姣忎釜鏁存暟閮藉彲浠ラ€掑锛屽苟涓斿彲浠ュ澶у埌澶т簬涓€浣嶆暟鐨勬暣鏁帮紝濡侶TTP/2.4姣擧TTP/2.13浣庯紝鑰孒TTP/2.4鍙堟瘮HTTP/12.3浣庛€傚墠瀵?蹇呴』琚帴鏀惰€呭拷鐣ュ苟涓斾笉鑳借鍙戦€佽€呭彂閫併€?/p>
涓€涓簲鐢ㄧ▼搴忓彂閫佽姹傛垨鍝嶅簲娑堟伅锛屽鏋滆姹傛垨鍝嶅簲娑堟伅閲岀殑HTTP-Version鏄?rdquo;HTTP/1.1”锛岄偅涔堟搴旂敤绋嬪簭蹇呴』鏉′欢閬靛惊姝ゅ崗璁鑼冦€傛渶灏戞潯浠堕伒寰瑙勮寖鐨勫簲鐢ㄧ▼搴忓簲璇ユ妸”HTTP/1.1”鍖呭惈鍦ㄤ粬浠殑娑堟伅閲岋紝骞朵笖瀵逛换浣曚笉鍏煎HTTP/1.1鐨勬秷鎭繀椤昏繖涔堝仛銆傚叧浜庝綍鏃跺彂閫佺壒瀹氱殑HTTP-Version鍊肩殑缁嗚妭锛屽弬瑙丷FC2145銆?/p>
搴旂敤绋嬪簭鐨凥TTP鐗堟湰鏄簲鐢ㄧ▼搴忔渶灏戞潯浠堕伒寰殑鏈€楂楬TTP鐗堟湰銆?/p>
浠g悊锛坧roxy锛夊拰缃戝叧锛坓ateway锛夊簲鐢ㄧ▼搴忛渶瑕佽浠旂粏瀵瑰緟锛屽綋杞彂锛坒orwarding锛夋秷鎭殑鍗忚鐗堟湰涓嶅悓浜庝唬鐞嗘垨缃戝叧搴旂敤绋嬪簭鐨勫崗璁増鏈€傚洜涓烘秷鎭噷鍗忚鐗堟湰璇存槑浜嗗彂閫佽€呭鐞嗗崗璁殑鑳藉姏锛屾墍浠ヤ竴涓唬鐞?缃戝叧鍗冧竾涓嶈鍙戦€佷竴涓珮浜庤浠g悊/缃戝叧搴旂敤绋嬪簭鍗忚鐗堟湰鐨勬秷鎭€傚鏋滀唬鐞嗘垨缃戝叧鎺ユ敹浜嗕竴涓洿楂樼増鏈殑娑堟伅锛屽畠涔熷繀椤昏闄嶄綆璇锋眰鐨勭増鏈紝瑕佷箞浠ヤ竴涓敊璇搷搴旓紝瑕佷箞鍒囨崲鍒伴毀閬撹涓猴紙tunnel behavior锛夈€?/p>
鐢变簬鑷粠RFC 2068[33]鍙戝竷鍚庯紝浜х敓浜嗕笌HTTP/1.0浠g悊锛坧roxy锛夌殑浜掓搷浣滈棶棰橈紝鎵€浠ョ紦瀛樹唬鐞嗭紙caching proxy锛夊繀椤昏兘鏀瑰彉璇锋眰锛坮equest锛夛紝浣胯姹傝兘鍒拌揪浠栦滑鑳芥敮鎸佺殑鏈€楂樼増鏈紝浣嗙綉鍏筹紙gateway锛夊彲浠ヨ繖涔堝仛涔熷彲浠ヤ笉杩欎箞鍋氾紝鑰宼unnel涓嶈兘杩欎箞鍋氥€備唬鐞嗭紙Proxy锛?缃戝叧锛坓ateway锛夌殑鍝嶅簲锛圧esponse锛夊繀椤诲拰璇锋眰锛坮equest锛夌殑HTTP鐗堟湰鐨刴ajor鏁板瓧鐩稿悓銆?/p>
娉ㄦ剰锛氬湪HTTP鐗堟湰闂寸殑杞崲鍙兘鍖呭惈澶村煙锛坔eader field锛夌殑鏀瑰彉锛岃€岃繖浜涙敼鍙樹細鍙兘浼氭牴鎹瓾TTP鐗堟湰鑰岃瑕佹眰鎴栬鎷掔粷銆?/p>
3.2 缁熶竴璧勬簮鏍囪瘑绗︼紙URI锛?br />URIs鐨勮澶氬悕瀛楀凡涓轰汉鎵€鐭ワ細WWW鍦板潃锛岄€氱敤鏂囨。鏍囪瘑绗︼紝閫氱敤璧勬簮鏍囪瘑绗3]锛屼互鍙婂悗鏉ョ殑缁熶竴璧勬簮瀹氫綅鍣紙URL锛塠4]鍜岀粺涓€璧勬簮鍚嶇О锛圲RN锛塠20]銆傚氨HTTP鑰岃█锛岀粺涓€璧勬簮瀹氫綅鍣ㄥ彧鏄牸寮忓寲鐨勫瓧绗︿覆锛屽畠閫氳繃鍚嶇О锛屽湴鍧€锛屾垨浠讳綍鍒殑鐗瑰緛璇嗗埆璧勬簮銆?/p>
3.2.1涓€鑸娉?br />鏍规嵁浣跨敤鐨勮儗鏅紝HTTP閲岀殑URI鍙互琛ㄧず鎴愮粷瀵癸紙absoulute锛夊舰寮忔垨鐩稿褰㈠紡锛堢浉瀵逛簬宸茬煡鐨刄RL锛夈€備袱绉嶅舰寮忕殑鍖哄埆鏄牴鎹繖鏍风殑浜嬪疄锛氱粷瀵筓RI鎬绘槸浠ヤ竴涓柟妗堬紙scheme锛夊悕浣滀负寮€澶达紝鍏跺悗鏄竴涓啋鍙枫€傚叧浜嶶RL鏇磋灏界殑淇℃伅璇峰弬鐪?缁熶竴璧勬簮鏍囪瘑绗︼紙URI锛?涓€鑸娉曞拰璇箟"锛孯FC 2396 [42]锛堜唬鏇夸簡RFCs 1738 [4]鍜孯FC 1808 [11]锛夈€傛湰瑙勮寖閲囩敤浜哛FC 2396閲岀殑"URI-reference"锛?absoluteURI"锛?relativeURI"锛?port"锛?host"锛?abs_path"锛?rel_path",鍜?authority"鐨勫畾涔夋牸寮忋€?/p>
HTTP鍗忚涓嶅URI鐨勯暱搴︿綔浜嬪厛鐨勯檺鍒讹紝鏈嶅姟鍣ㄥ繀椤昏兘澶熷鐞嗗畠浠祫婧愮殑URI锛屽苟涓斿簲璇ヨ兘澶熷鐞嗘棤闄愰暱搴︾殑URI锛岃繖绉嶆棤鏁堥暱搴︾殑URL鍙兘浼氬湪瀹㈡埛绔互GET褰㈠紡鐨勮姹備骇鐢熴€傛湇鍔″櫒搴旇杩斿洖414鐘舵€佺爜锛堟鐘舵€佺爜浠h〃Request-URI澶暱锛夛紝濡傛灉鏈嶅姟鍣ㄤ笉鑳藉鐞嗗お闀跨殑URI鐨勬椂鍊欍€?/p>
娉?鏈嶅姟鍣ㄥ湪渚濊禆澶т簬255瀛楄妭鐨刄RI鏃跺簲璋ㄦ厧锛屽洜涓轰竴浜涙棫鐨勫鎴锋垨浠g悊瀹炵幇鍙兘涓嶆敮鎸佽繖浜涢暱搴︺€?/p>
3.2.2 http URL
閫氳繃HTTP鍗忚锛宧ttp鏂规锛坔ttp scheme锛夎鐢ㄤ簬瀹氫綅缃戠粶璧勬簮锛坮esourse锛夌殑浣嶇疆銆傛湰鑺傚畾涔変簡杩欑鏂规鐨勮娉曞拰璇箟銆?/p>
http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
濡傛灉绔彛涓虹┖鎴栨湭缁欏嚭锛屽氨鍋囧畾涓?0銆傝涔夊嵆锛氬凡璇嗗埆鐨勮祫婧愭斁鍦ㄦ湇鍔″櫒涓婏紝鍦ㄩ偅鍙颁富鏈虹殑閭d釜绔彛涓婄洃鍚琓CP杩炴帴銆傝繖鏃惰祫婧愮殑璇锋眰鐨刄RI涓虹粷瀵硅矾寰勶紙5.1.2鑺傦級銆傛棤璁轰粈涔堝彲鑳界殑鏃跺€欙紝URL閲屼娇鐢↖P鍦板潃閮芥槸搴旇閬垮厤鐨勶紙鍙傜湅RFC 1900 [24]锛夈€傚鏋滅粷瀵瑰湴鍧€锛坅bs_path锛夋病鏈夊嚭鐜板湪URL閲岋紝閭d箞搴旇缁欏嚭"/"銆傚鏋滀唬鐞嗭紙proxy锛夋敹鍒颁竴涓富鏈猴紙host锛夊悕锛屼絾鏄繖涓富鏈哄悕涓嶆槸鍏ㄧО鐨勫煙鍚嶏紙fully quanlified domain name锛夛紝鍒欎唬鐞嗗簲璇ユ妸瀹冪殑鍩熷悕鍔犲埌涓绘満鍚嶄笂銆傚鏋滀唬鐞嗭紙proxy锛夋帴鏀朵簡涓€涓叏绉扮殑鍩熷悕锛屼唬鐞嗕笉蹇呮敼鍙樹富鏈恒€?/p>
3.2.3 URI 姣旇緝
褰撴瘮杈冧袱涓猆RI鏄惁鍖归厤鏃讹紝瀹㈡埛搴旇瀵规暣涓猆RI姣旇緝鏃跺簲璇ュ尯鍒嗗ぇ灏忓啓锛屽苟涓斾竴涓瓧鑺備竴涓瓧鑺傜殑姣旇緝銆?浣嗕笅闈㈡湁浜涚壒娈婃儏鍐碉細
- 涓€涓负绌烘垨鏈粰瀹氱殑绔彛绛夊悓浜嶶RI-refernece锛堣RFC 2396锛夐噷鐨勯粯璁ょ鍙?
- 涓绘満锛坔ost锛夊悕鐨勬瘮杈冨繀椤讳笉蹇呭垎澶у皬鍐?
- 鏂规锛坰cheme锛夊悕鐨勬瘮杈冨繀椤绘槸涓嶅尯鍒嗗ぇ灏忓啓鐨?
- 涓€涓┖缁濆璺緞锛坅bs_path锛夌瓑鍚屼簬"/"銆?/p>
闄や簡"淇濈暀锛坮eserved锛?鍜?涓嶅畨鍏紙unsafe锛?瀛楃闆嗛噷鐨勫瓧绗︼紙鍙傝RFC 2396 [42]锛?锛屽叾瀹冨瓧绗﹂兘绛夋晥浜庡畠浠殑"%HEXHEX"缂栫爜.
渚嬪,浠ヤ笅涓変釜URI鏄瓑鍚岀殑:
http://abc.com:80/~smith/home.html
http://ABC.com/%7Esmith/home.html
http://ABC.com:/%7esmith/home.html
3.3 鏃ユ湡/鏃堕棿鏍煎紡锛圖ate/Time Formats锛?br />3.3.1瀹屾暣鏃ユ湡 锛團ull Date锛?br /> HTTP搴旂敤鏇剧粡涓€鐩村厑璁镐笁绉嶄笉鍚屾棩鏈?鏃堕棿鏍煎紡锛?/p>
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C鈥榮 asctime锛堬級 format
绗竴绉嶆牸寮忔槸浣滀负Internet鏍囧噯鎻愬嚭鏉ョ殑锛屽畠鏄竴涓浗瀹氶暱搴︾殑锛岀敱RFC 1123 [8]锛圧FC 822[9]鐨勫崌绾х増鏈級瀹氫箟鐨勪竴涓瓙闆嗐€傜浜岀鏍煎紡浣跨敤姣旇緝鏅亶锛屼絾鏄熀浜庡簾寮冪殑RFC 850 [12]锛屽苟涓旀病鏈夊勾浠姐€傚鏋淗TTP/1.1瀹㈡埛绔拰鏈嶅姟鍣ㄨВ鏋愭棩鏈燂紝浠栦滑蹇呴』鑳芥帴鏀舵墍鏈変笁绉嶆牸寮忥紙涓轰簡鍏煎HTTP/1.0锛夛紝浣嗘槸瀹冧滑鍙兘浜х敓RFC 1123閲屽畾涔夌殑鏃ユ湡鏍煎紡鏉ュ~鍏呭ご鍩燂紙header field锛夌敤鍒版棩鏈熺殑鍦版柟銆?/p>
娉?鏃ユ湡鍊肩殑鎺ユ敹鑰呰榧撳姳鑳藉仴澹殑鎺ユ敹鍙兘鐢遍潪HTTP搴旂敤鍙戞潵鐨勬棩鏈熷€硷紝渚嬪鏈夋椂鍙互閫氳繃浠g悊锛坧roxy锛?缃戝叧锛坓ateway锛夊悜SMTP鎴朜NTP鑾峰緱鎴栬浆鍙戞秷鎭€?/p>
鎵€鏈夌殑HTTP鏃ユ湡/鏃堕棿閮藉繀椤讳互鏍兼灄濞佹不鏃堕棿锛圙MT锛夎〃绀恒€傚HTTP鑰岃█锛孏MT瀹屽叏绛夊悓浜嶶TC锛堜笘鐣屽崗璋冩椂闂达級銆傚墠涓ょ鏃ユ湡/鏃堕棿鏍煎紡閲屽寘鍚?ldquo;GMT”锛屽畠鏄椂鍖虹殑涓変釜瀛楅潰鐨勭畝鍐欙紝骞朵笖褰撹鍒颁竴涓猘sctime鏍煎紡鏃跺繀椤诲厛琚亣瀹氭槸GMT鏃堕棿銆侶TTP鏃ユ湡锛圚TTP-date锛夊尯鍒嗗ぇ灏忓啓锛屼笉鑳藉寘鍚竴涓澶栫殑LWS锛岄櫎闈炴LWS浣滀负鍦ㄤ笅闈㈢殑Http-date璇硶涓寚瀹氱殑SP銆?/p>
HTTP-date = rfc1123-date | rfc850-date | asctime-date
rfc1123-date = wkday "," SP date1 SP time SP "GMT"
rfc850-date = weekday "," SP date2 SP time SP "GMT"
asctime-date = wkday SP date3 SP time SP 4DIGIT
date1 = 2DIGIT SP month SP 4DIGIT
; day month year 锛坋.g., 02 Jun 1982锛?/p>
date2 = 2DIGIT "-" month "-" 2DIGIT
; day-month-year 锛坋.g., 02-Jun-82锛?/p>
date3 = month SP 锛?2DIGIT | 锛?SP 1DIGIT 锛夛級
; month day 锛坋.g., Jun 2锛?/p>
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; 00:00:00 - 23:59:59
wkday = "Mon" | "Tue" | "Wed"
| "Thu" | "Fri" | "Sat" | "Sun"
weekday = "Monday" | "Tuesday" | "Wednesday"
| "Thursday" | "Friday" | "Saturday" | "Sunday"
month = "Jan" | "Feb" | "Mar" | "Apr"
| "May" | "Jun" | "Jul" | "Aug"
| "Sep" | "Oct" | "Nov" | "Dec"
娉ㄦ剰:HTTP瀵规棩鏈?鏃堕棿鏍煎紡鐨勮姹備粎浠呭簲鐢ㄥ湪鍗忚鐨勬秷鎭紙璇戞敞:鍘熸枃鏄痯rotocol stream锛屼究浜庣悊瑙h繖閲岃瘧浣滄秷鎭級閲屻€傚鎴峰拰鏈嶅姟鍣ㄤ笉蹇呮妸杩欑鏍煎紡搴旂敤浜庣敤鎴峰憟鐜帮紙user presentation锛夛紝璇锋眰璁板綍鏃ュ織锛岀瓑绛夈€?
3.3.2 Delta Seconds
涓€浜汬TTP澶村煙锛坔eader field锛夊厑璁哥敤鏁存暟绉掕〃绀烘椂闂村€硷紝鏁存暟绉掔敤鍗佽繘鍒惰〃绀猴紝姝ゆ暣鏁扮琛ㄧず娑堟伅琚帴鏀跺悗鏃堕棿銆?/p>
delta-seconds = 1*DIGIT
3.4 瀛楃闆?br /> HTTP浣跨敤鏈"瀛楃闆?鐨勫畾涔夛紝杩欏拰MIME涓墍鎻忚堪鐨勬槸涓€鏍?
鏈枃妗d腑鐨勬湳璇?瀛楃闆?娑夊強鍒颁竴绉嶆柟娉曪紝姝ゆ柟娉曟槸鐢ㄤ竴涓垨澶氫釜琛ㄥ皢涓€涓妭搴忓垪杞崲鎴愪竴涓瓧绗﹀簭鍒楋紙璇戞敞锛氫粠杩欓噷鏉ョ湅锛岃繖搴旇鏄竴绉嶆槧灏勫叧绯伙紝琛ㄤ繚瀛樹簡鏄犲皠鍏崇郴锛夈€傛敞鎰忓弽鏂瑰悜鐨勬棤鏉′欢杞崲锛堣瘧娉?浠庝竴涓瓧绗﹀簭鍒楀埌涓€涓瓧鑺傚簭鍒楃殑杞崲锛夋槸涓嶉渶瑕佺殑锛屽洜涓哄苟涓嶆槸鎵€鏈夌殑瀛楃閮借兘鍦ㄤ竴涓粰瀹氱殑瀛楃闆嗛噷寰楀埌锛屼竴涓瓧绗﹂泦鍙兘鎻愪緵澶氫釜瀛楄妭搴忓垪琛ㄥ緛涓€涓壒瀹氱殑瀛楃銆傝繖涓畾涔夋槸涓轰簡鍏佽涓嶅悓绉嶇被鐨勫瓧绗︾紪鐮佷粠鍗曚竴绠€鍗曡〃鏄犲皠锛堝US-ASCII锛夊埌澶嶆潅琛ㄧ殑杞崲鏂规硶濡侷SO-2022鎶€鏈敤鍒扮殑銆傜劧鑰岋紝涓嶮IME瀛楃闆嗗悕瀛楃浉鍏崇殑瀹氫箟蹇呴』瑕佸厖鍒嗚鏄庝粠瀛楄妭鍒板瓧绗︾殑鏄犲皠銆傜壒鍒殑锛屼娇鐢ㄥ閮ㄨ疆寤撲俊鎭潵绮剧‘纭畾鏄犲皠鏄笉鍏佽鐨?
娉?杩欓噷浣跨敤鐨勬湳璇?瀛楃闆?涓€鑸殑琚О浣滀竴绉?瀛楃缂栫爜"銆備笉杩囨棦鐒禜TTP鍜孧IME鍦ㄥ悓涓€鏈烘瀯娉ㄥ唽锛屾湳璇粺涓€鏄緢閲嶈鐨勩€?/p>
HTTP瀛楃闆嗘槸鐢ㄤ笉鍖哄垎澶у皬鍐欑殑鏍囪锛坱oken锛夎〃绀恒€傛墍鏈夌殑鏍囪闆嗙敱IANA瀛楃闆嗘敞鍐屾満鏋刐19]瀹氫箟銆?/p>
charset = token
灏界HTTP鍏佽鐢ㄤ换鎰忔爣璁帮紙token锛変綔涓哄瓧绗﹂泦锛坈harset锛夊€硷紝浣嗕换浣曟爣璁板€煎鏋滃畠宸茬粡鍦↖ANA瀛楃闆嗘敞鍐屾満鏋勬敞鍐屼簡鍒欏繀椤昏〃绀哄湪璇ユ敞鍐屾満鏋勫畾涔夌殑瀛楃闆嗐€傚閭d簺闈濱ANA瀹氫箟鐨勫瓧绗﹂泦锛屽簲鐢ㄧ▼搴忓簲璇ラ檺鍒朵娇鐢ㄣ€?/p>
HTTP鍗忚鐨勫疄鐜拌€呭簲璇ユ敞鎰廔ETF瀛楃闆嗙殑瑕佹眰[38][41].
3.4.1涓㈠け鐨勫瓧绗﹂泦锛圡issing Charset锛?br />涓€浜汬TTP/1.0搴旂敤绋嬪簭褰撲粬浠В鏋怌ontent-Type澶存椂锛屽綋鍙戠幇娌℃湁瀛楃闆嗗弬鏁帮紙charset parameter锛岃瘧娉?Content-Type: text/plain; charset=UTF-8锛屾鏃禼harset=UTF-8灏辨槸瀛楃闆嗗弬鏁帮級鍙敤鏃讹紝杩欐剰鍛崇潃鎺ユ敹鑰呭繀椤荤寽娴嬪疄浣撲富浣擄紙entity body锛岃瘧娉細杩欓噷缈昏瘧鎴?ldquo;瀹炰綋涓讳綋”鍥犱负Content-Type澶存槸瀹炰綋澶达紝娑堟伅澶村彲浠ュ垎涓哄疄浣撳ご锛屽父鐢ㄥご锛岃姹傚ご锛屽搷搴斿ご锛屽湪璇戞枃涓娆$敤鍒?ldquo;澶?rdquo;鍜?ldquo;澶村煙”锛屽娑堟伅澶达紝娑堟伅澶村煙锛屽叾瀹炴槸鍚屼竴涓剰鎬濓紝HTTP1.1鍗忚鏈夋椂鍊欐蹇靛苟涓嶆槸瀹屽叏缁熶竴鐨勶級鐨勫瓧绗﹂泦鏄粈涔堛€傚鏋滃彂閫佽€呭笇鏈涢伩鍏嶈繖绉嶆儏鍐碉紝浠栧簲璇ュ湪Content-Type澶村煙閲屽寘鍚竴涓瓧绗﹂泦鍙傛暟锛屽嵆浣垮瓧绗﹂泦鏄疘SO-8859-1涔熷簲璇ヨ繖鏍峰仛锛岃繖鏍峰氨涓嶄細璁╂帴鏀惰€呬骇鐢熸贩娣嗐€?/p>
涓嶅垢鐨勬槸锛屼竴浜涙棫鐨凥TTP/1.0瀹㈡埛绔笉鑳藉鐞嗗湪Content-Type澶村煙閲屾槑纭寚瀹氱殑瀛楃闆嗗弬鏁般€侶TTP/1.1鎺ユ敹绔繀椤昏璁ょ湡瀵瑰緟鍙戦€佽€呮彁渚涚殑瀛楃闆嗭紱骞朵笖褰撶敤鎴蜂唬鐞嗭紙user agent锛岃瘧娉細濡傛祻瑙堝櫒锛屽彲璁や负鏄帴鏀剁锛夊紑濮嬫樉绀轰竴涓枃妗f椂锛岃櫧鐒剁敤鎴蜂唬鐞嗗彲浠ョ寽娴嬫枃妗g殑瀛楃闆嗭紝浣嗗鏋渃ontent-type澶村煙閲屾彁渚涗簡瀛楃闆嗭紝骞朵笖鐢ㄦ埛浠g悊涔熸敮鎸佽繖绉嶅瓧绗﹂泦鐨勬樉绀猴紝涓嶇鐢ㄦ埛浠g悊鏄惁鎰挎剰锛屽畠蹇呴』瑕佸埄鐢ㄨ繖绉嶅瓧绗﹂泦銆傚弬瑙?.7.1鑺傘€?/p>
3.5 鍐呭缂栫爜锛圕ontent Codings锛?nbsp;
鍐呭缂栫爜鍊硷紙content coding value锛夎〃绀轰竴绉嶅凡缁忔垨鍙互搴旂敤浜庡疄浣撶殑缂栫爜杞崲锛坋ncoding transformation锛夈€傚唴瀹圭紪鐮佷富瑕佺敤浜庢枃妗g殑鍘嬬缉鎴栧叾瀹冩湁鏁堢殑鍙樻崲锛屼絾杩欑鍙樻崲闇€瑕佷笉鑳戒涪澶辨枃妗g殑濯掍綋绫诲瀷锛坢edia type锛岃瘧娉細鏂囨。涓€鑸細鏈夊獟浣撶被鍨嬶紝杩欓€氳繃鍦╟ontent-type閲屾寚瀹氾級鐨勭壒鎬э紝涔熶笉鑳戒涪澶辨枃妗g殑淇℃伅锛堣瘧娉細灏卞儚鏈夋崯鍘嬬缉鍜屾棤鎹熷帇缂╋紝鍓嶈€呬笉浼氫涪澶变俊鎭紝鍚庤€呬細涓㈠け淇℃伅锛夈€傚疄浣撶粡甯歌缂栫爜鐨勫偍瀛橈紝鐒跺悗鐩存帴浼犻€侊紝鎺ユ敹绔彧鑳借В鐮併€?/p>
content-coding = token
鎵€鏈夊唴瀹圭紪鐮佸€硷紙content-coding value锛夋槸涓嶅尯鍒嗗ぇ灏忓啓鐨勩€侶TTP/1.1鍦ㄦ帴鏀惰瘧鐮?锛?4.3鑺傦級鍜屽唴瀹硅瘧鐮侊紙Content-Encoding锛夛紙14.11鑺傦級澶村煙閲屼娇鐢ㄥ唴瀹圭紪鐮佸€硷紙content-coding value锛夈€傚敖绠¤鍊兼弿杩颁簡鍐呭缂栫爜锛屾洿閲嶈鐨勬槸瀹冩寚鍑轰簡涓€绉嶈В鐮佹満鍒讹紝鍒╃敤杩欑鏈哄埗瀵瑰疄浣撶殑缂栫爜杩涜瑙g爜銆?/p>
缃戠粶鍒嗛厤鏁板瓧鏉冨▉锛?锛圛ANA锛夊厖褰撳唴瀹圭紪鐮佸€兼爣璁帮紙token锛夌殑娉ㄥ唽鏈烘瀯銆傛渶鍒濓紝娉ㄥ唽琛ㄩ噷鍖呭惈涓嬪垪鏍囪:
gzip锛堝帇缂╃▼搴忥級
涓€绉嶇敱鏂囦欢鍘嬬缉绋嬪簭"gzip"锛圙NU zip锛変骇鐢熺殑缂栫爜鏍煎紡锛堝湪RFC 1952涓弿杩帮級銆傝繖绉嶇紪鐮佹牸寮忔槸涓€绉嶅叿鏈?2浣岰RC鐨凩empel-Ziv缂栫爜锛圠Z77锛夈€?/p>
compress锛堝帇缂╋級
涓€绉嶇敱UNIX鏂囦欢鍘嬬缉绋嬪簭"compress"浜х敓鐨勭紪鐮佹牸寮忋€傝繖绉嶇紪鐮佹牸寮忔槸涓€绉嶅叿鏈夊彲閫傚簲鎬х殑Lempel-Ziv-Welch缂栫爜锛圠ZW锛夈€?/p>
瀵逛簬灏嗘潵鐨勭紪鐮侊紝鐢ㄧ▼搴忓悕璇嗚〃寰佺紪鐮佹牸寮忔槸涓嶅彲鍙栥€傚湪杩欓噷鐢ㄥ埌浠栦滑鏄洜涓轰粬浠湪鍘嗗彶鐨勪綔鐢紝铏界劧杩欐牱鍋氬苟涓嶅ソ銆備负浜嗗悓浠ュ墠鐨凥TTP瀹炵幇鐩稿吋瀹癸紝搴旂敤绋嬪簭搴旇灏?x-gzip"鍜?x-compress"鍒嗗埆绛夊悓浜?gzip"鍜?compress"銆?/p>
deflate锛堢缉灏忥級銆€
deflate缂栫爜鏄敱RFC 1950 [31]瀹氫箟鐨?zlib"缂栫爜鏍煎紡涓嶳FC 1951 [29]閲屾弿杩扮殑"deflate"鍘嬬缉鏈哄埗鐨勭粍鍚堢殑浜х墿銆?/p>
identity锛堜竴鑷存€э級
Identity鏄己鐪佺紪鐮侊紱鎸囨槑杩欑缂栫爜琛ㄦ槑涓嶈繘琛屼换浣曠紪鐮佽浆鎹€傝繖绉嶅唴瀹圭紪鐮佷粎琚敤浜庢帴鏀惰瘧鐮侊紙Accept-Encoding锛夊ご鍩燂紝浣嗕笉鑳借鐢ㄥ湪鍐呭璇戠爜锛圕ontent-Encoding锛夊ご鍩熴€?
鏂扮殑鍐呭缂栫爜鍊兼爣璁帮紙token锛夊簲璇ヨ娉ㄥ唽锛涗负浜嗗疄鐜板鎴峰拰鏈嶅姟鍣ㄩ棿鐨勪簰鎿嶄綔鎬э紝瀹炵幇鏂板€肩殑鍐呭缂栫爜绠楁硶瑙勮寖搴旇鑳藉叕寮€鍒╃敤骞朵笖鑳界嫭绔嬪疄鐜帮紝骞朵笖涓庢湰鑺備腑琚畾涔夌殑鍐呭缂栫爜鐩殑鐩镐竴鑷淬€?/p>
3.6 浼犺緭缂栫爜 锛圱ransfer Codings锛?br />浼犺緭缂栫爜鍊硷紙transfer-coding value锛岃瘧娉細transfer coding鍜屽拰transfer-coding杩欎袱涓湳璇湪鏈崗璁鑼冮噷鎵€琛ㄨ揪鐨勬剰鎬濆叾瀹炴病浠€涔堝お澶у尯鍒紝“transfer-coding”鍙兘鏇磋兘琛ㄨ揪璇剰锛屽洜涓哄畠鏄鍒欎腑鐨勮鍒欏悕锛岃涓嬮潰绾㈠瓧鐨勮鍒欙級琚敤鏉ヨ〃绀轰竴涓凡缁忥紝鑳藉锛屾垨鍙兘搴旂敤浜庝竴涓疄浣撶殑缂栫爜杞崲锛屼紶杈撶紪鐮佹槸涓轰簡鑳藉纭繚缃戠粶瀹夊叏浼犺緭銆傝繖涓嶅悓浜庡唴瀹圭紪鐮侊紙content coding锛夛紝鍥犱负浼犺緭缂栫爜锛坱ransfer coding锛夋槸娑堟伅鐨勫睘鎬ц€屼笉鏄疄浣撶殑灞炴€с€?/p>
transfer-coding = "chunked" | transfer-extension
transfer-extension = token *锛?";" parameter 锛?/p>
鍙傛暟锛坧arameter锛夐噰鐢ㄥ睘鎬?鍊煎鐨勫舰寮?
parameter = attribute "=" value
attribute = token
value = token | quoted-string
鎵€鏈変紶杈撶紪鐮佸€硷紙transfer-coding value锛岃瘧娉細涓婇潰绾綋瀛楃瓑鍙峰彸杈硅鍒欒〃杈惧紡鎵€琛ㄨ揪鐨勫€硷級鏄ぇ灏忓啓涓嶆晱鎰熴€備紶杈撶紪鐮佸€煎湪TE澶村煙锛?4.39鑺傦級鍜屽湪浼犺緭璇戠爜锛圱ransfer-encoding锛?澶村煙涓紙14.41鑺傦級琚繍鐢ㄣ€?/p>
鏃犺浣曟椂锛屼紶杈撶紪鐮侊紙transfer-coding锛夊簲鐢ㄤ簬涓€涓秷鎭富浣擄紙message body锛夋椂锛屽鏋滃瓨鍦ㄥ涓紶杈撶紪鐮侊紝鍒欒繖浜涗紶杈撶紪鐮佷腑蹇呴』鍖呮嫭“鍧?rdquo;锛?chunked"锛変紶杈撶紪鐮侊紝闄ら潪閫氳繃鍏抽棴杩炴帴鑰屼腑鏂秷鎭€傚綋“鍧?rdquo;锛?ldquo;chunked”锛変紶杈撶紪鐮佽鐢ㄤ簬浼犺緭缂栫爜鏃讹紝瀹冨繀椤绘槸搴旂敤浜庢秷鎭富浣撶殑鏈€鍚庝紶杈撶紪鐮併€?鍧?锛?chunked"锛変紶杈撶紪鐮佹渶澶氬彧鑳界敤浜庢秷鎭富浣擄紙message-body锛変竴娆°€傝瀹氫簡涓婅堪瑙勫垯鍚庯紝鎺ユ敹鑰呭氨鍙互纭畾娑堟伅鐨勪紶杈撻暱搴︼紙transfer-length锛夛紙4.4鑺傦級
浼犺緭缂栫爜涓嶮IME[7]鐨勫唴瀹逛紶杈撹瘧鐮侊紙Content-Transfer-Encoding锛岃瘧娉細transfer搴旇鏄浆绉伙紝杩佺Щ鐨勬剰鎬濓紝鍙堜緥濡侶TTP鍗忚锛屽簲璇ョ炕璇戞垚“瓒呮枃鏈浆绉诲崗璁?rdquo;锛屼絾鏄巻鍙蹭笂閮界炕璇戞垚“瓒呮枃鏈紶杈撳崗璁?rdquo;锛屾墍浠ヨ繖閲岀炕璇戞垚“瓒呮枃鏈紶杈撳崗璁?rdquo;锛夊€兼湁鐩哥被浼煎瀷锛屽畠琚畾涔夎兘澶熷疄鐜板湪7浣嶄紶杈撴湇鍔′笂淇濊瘉浜岃繘鍒舵暟鎹殑浼犺緭瀹夊叏銆備笉杩囷紝浼犺緭缂栫爜涓庡唴瀹逛紶杈撹瘧鐮侊紙Content-Transfer-Encoding锛夊绾?浣嶄紶杈撳崗璁湁涓嶅悓鐨勫叧娉ㄧ偣銆傚湪HTTP涓紝娑堟伅涓讳綋瀛樺湪涓嶅畨鍏ㄧ殑闅愭偅锛屽洜涓烘湁鏃跺€欏緢闅剧‘瀹氭秷鎭富浣撶殑闀垮害锛屽湪鍏变韩鐨勪紶杈撲笂鍔犲瘑鏁版嵁涔熶細甯︽潵瀹夊叏鎬ч棶棰橈紙7.2.2鑺傦級銆?/p>
缃戠粶鍒嗛厤鏁板瓧鏉冨▉锛圛ANA锛夋媴浠绘敞鍐屼紶杈撶紪鐮佸€兼爣锛坱oken锛夎鐨勮鑹层€傝捣鍒?娉ㄥ唽鍖呭惈濡備笅鏍囪:"鍧?锛?.6.1鑺傦級,"韬唤"锛?.6.2鑺傦級,"gzip"锛?.5鑺傦級,"鍘嬬缉"锛?.5鑺傦級,鍜?缂╁皬"锛?.5鑺傦級.
鏂扮殑浼犺緭缂栫爜鍊兼爣璁板簲璇ユ敞鍐岋紝杩欏悓鏂扮殑鍐呭缂栫爜鍊兼爣璁颁篃闇€瑕佹敞鍐屼竴鏍枫€?
鎺ユ敹绔帴鏀跺埌涓€涓甫鏈変紶杈撶紪鐮侊紙transfer-coding锛夛紙璇戞敞锛氶€氳繃娑堟伅澶村煙transfer-encoding鎸囨槑姝ゅ疄浣撲富浣撶殑浼犺緭缂栫爜锛夌殑瀹炰綋涓讳綋锛坋ntity body锛夛紝濡傛灉瀹冧笉鑳藉杩欎釜缂栫爜鍚庣殑瀹炰綋涓讳綋杩涜瑙g爜锛岄偅涔堝畠搴旇繑鍥?01锛堜笉鑳藉疄鐜帮級锛屽苟涓旇鍒囨柇鑱旂郴銆傛湇鍔″櫒涓嶈兘鍚慔TTP/1.0瀹㈡埛鍙戦€佷紶杈撶紪鐮?
3.6.1鍧椾紶杈撶紪鐮侊紙Chunked Transfer Coding锛?nbsp;
鍧楃紪鐮侊紙chunked encoding锛夋敼鍙樻秷鎭富浣撲娇娑堟伅涓讳綋锛坢essage body锛岃瘧娉細娑堟伅涓讳綋涓庡疄浣撲富浣撴槸鏈夊尯鍒殑锛屽悗闈㈢珷鑺傚皢浼氫粙缁嶏級鎴愬潡鍙戦€併€傛瘡涓€涓潡鏈夊畠鑷繁鐨勫ぇ灏忥紙size锛夋寚绀哄櫒锛屽湪鎵€鏈夌殑鍧椾箣鍚庝細绱ф帴鐫€涓€涓彲閫夌殑鍖呭惈瀹炰綋澶村煙鐨勫熬閮紙trailer锛夈€傝繖鍏佽鍙戦€佺鑳藉姩鎬佺敓鎴愬唴瀹癸紝骞惰兘鎼哄甫鏈夌敤鐨勪俊鎭紝杩欎簺淇℃伅鑳借鎺ユ敹鑰呭垽鏂秷鎭槸鍚︽帴鏀跺畬鏁淬€?/p>
Chunked-Body锛堝潡姝f枃锛?nbsp; = *chunk锛堝潡锛?/p>
last-chunk锛堟渶鍚庡潡锛?/p>
trailer锛堝熬閮級
CRLF
chunk锛堝潡锛?nbsp; = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*锛?0"锛?[ chunk-extension ] CRLF
chunk-extension= *锛?";" chunk-ext-name [ "=" chunk-ext-val ] 锛?nbsp;
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size锛圤CTET锛?/p>
trailer = *锛坋ntity-header CRLF锛?/p>
chunk-size鏄敤16 杩涘埗鏁板瓧瀛楃涓层€傚潡缂栫爜锛坈hunked encoding锛変互浠讳竴澶у皬涓?鐨勫潡缁撴潫锛岀揣鎺ョ潃鏄熬閮紙trailer锛夛紝灏鹃儴浠ヤ竴涓┖琛岀粓姝€?/p>
灏鹃儴锛坱railer锛夊厑璁稿彂閫佺鍦ㄦ秷鎭殑鏈熬鍖呭惈闄勫姞鐨凥TTP澶村煙锛坔eader field锛夈€俆railer澶村煙锛圱railer header field锛岃瘧娉細Trailer澶存槸甯哥敤娑堟伅澶达紝鍦?4.40鑺傝鏄庯級琚簲鐢ㄦ潵鎸囨槑鍝簺澶村煙琚寘鍚湪鍧楃紪鐮佺殑灏鹃儴锛坱railer锛?锛堣14.40鑺傦級
濡傛灉鏈嶅姟鍣ㄨ鐢ㄥ潡浼犺緭缂栫爜杩涜鍝嶅簲锛屽畠涓嶈兘鍖呭惈灏鹃儴锛坱railer锛夛紝闄ら潪浠ヤ笅鑷冲皯涓€鏉′负鐪燂細
a锛夊鏋滄鍝嶅簲鐨勮姹傚寘鎷
以上是关于HTTP1.1鍗忚涓枃鐗?RFC2616的主要内容,如果未能解决你的问题,请参考以下文章
RFC2616-HTTP1.1-Header Field Definitions(头字段规定部分—单词注释版)