HTTP/2鍐呮牳鍓栨瀽
Posted 娣卞叆鍘熺悊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTTP/2鍐呮牳鍓栨瀽相关的知识,希望对你有一定的参考价值。
鐐瑰嚮馃憜钃濊壊鈥?nbsp;娣卞叆鍘熺悊鈥濓紝鍏虫敞骞垛€?/span>璁句负鏄熸爣鈥?/span>
鎶€鏈共璐э紝绗竴鏃堕棿鎺ㄩ€?/span>
浠婂ぉ鎴戜滑缁х画涓婁竴璁茬殑璇濋锛屾繁鍏?HTTP/2 鍗忚鐨勫唴閮紝鐪嬬湅瀹冪殑瀹炵幇缁嗚妭銆?/span>
杩欐瀹為獙鐜鐨?URI 鏄€?31-1鈥濓紝鎴戠敤 Wireshark 鎶婅姹傚搷搴旂殑杩囩▼鎶撳寘瀛樹簡涓嬫潵锛屾枃浠舵斁鍦?GitHub 鐨勨€渨ireshark鈥濈洰褰曘€備粖澶╂垜浠氨瀵圭収鐫€鎶撳寘鏉ュ疄鍦拌瑙?HTTP/2 鐨勫ご閮ㄥ帇缂┿€佷簩杩涘埗甯х瓑鐗规€с€?/span>
杩炴帴鍓嶈█
鐢变簬 HTTP/2鈥滀簨瀹炰笂鈥濇槸鍩轰簬 TLS锛屾墍浠ュ湪姝e紡鏀跺彂鏁版嵁涔嬪墠锛屼細鏈?TCP 鎻℃墜鍜?TLS 鎻℃墜锛岃繖涓や釜姝ラ鐩镐俊浣犱竴瀹氬凡缁忓緢鐔熸倝浜嗭紝鎵€浠ヨ繖閲屽氨鐣ヨ繃鍘讳笉鍐嶇粏璇淬€?/span>
TLS 鎻℃墜鎴愬姛涔嬪悗锛屽鎴风蹇呴』瑕佸彂閫佷竴涓€?/span>杩炴帴鍓嶈█鈥濓紙connection preface锛夛紝鐢ㄦ潵纭寤虹珛 HTTP/2 杩炴帴銆?/span>
杩欎釜鈥滆繛鎺ュ墠瑷€鈥濇槸鏍囧噯鐨?HTTP/1 璇锋眰鎶ユ枃锛屼娇鐢ㄧ函鏂囨湰鐨?ASCII 鐮佹牸寮忥紝璇锋眰鏂规硶鏄壒鍒敞鍐岀殑涓€涓叧閿瓧鈥淧RI鈥濓紝鍏ㄦ枃鍙湁 24 涓瓧鑺傦細
PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n
鍦?Wireshark 閲岋紝HTTP/2 鐨勨€滆繛鎺ュ墠瑷€鈥濊绉颁负鈥?/span>Magic鈥濓紝鎰忔€濆氨鏄€滀笉鍙煡鐨勯瓟娉曗€濄€?/span>
鎵€浠ワ紝灏变笉瑕侀棶鈥滀负浠€涔堜細鏄繖鏍封€濅簡锛屽彧瑕佹湇鍔″櫒鏀跺埌杩欎釜鈥滄湁榄斿姏鐨勫瓧绗︿覆鈥濓紝灏辩煡閬撳鎴风鍦?TLS 涓婃兂瑕佺殑鏄?HTTP/2 鍗忚锛岃€屼笉鏄叾浠栧埆鐨勫崗璁紝鍚庨潰灏变細閮戒娇鐢?HTTP/2 鐨勬暟鎹牸寮忋€?/span>
澶撮儴鍘嬬缉
纭珛浜嗚繛鎺ヤ箣鍚庯紝HTTP/2 灏卞紑濮嬪噯澶囪姹傛姤鏂囥€?/span>
鍥犱负璇箟涓婂畠涓?HTTP/1 鍏煎锛屾墍浠ユ姤鏂囪繕鏄敱鈥淗eader+Body鈥濇瀯鎴愮殑锛屼絾鍦ㄨ姹傚彂閫佸墠锛屽繀椤昏鐢ㄢ€?/span>HPACK鈥濈畻娉曟潵鍘嬬缉澶撮儴鏁版嵁銆?/span>
鈥淗PACK鈥濈畻娉曟槸涓撻棬涓哄帇缂?HTTP 澶撮儴瀹氬埗鐨勭畻娉曪紝涓?gzip銆亃lib 绛夊帇缂╃畻娉曚笉鍚岋紝瀹冩槸涓€涓€滄湁鐘舵€佲€濈殑绠楁硶锛岄渶瑕佸鎴风鍜屾湇鍔″櫒鍚勮嚜缁存姢涓€浠解€滅储寮曡〃鈥濓紝涔熷彲浠ヨ鏄€滃瓧鍏糕€濓紙杩欐湁鐐圭被浼?brotli锛夛紝鍘嬬缉鍜岃В鍘嬬缉灏辨槸鏌ヨ〃鍜屾洿鏂拌〃鐨勬搷浣溿€?/span>
涓轰簡鏂逛究绠$悊鍜屽帇缂╋紝HTTP/2 搴熼櫎浜嗗師鏈夌殑璧峰琛屾蹇碉紝鎶婅捣濮嬭閲岄潰鐨勮姹傛柟娉曘€乁RI銆佺姸鎬佺爜绛夌粺涓€杞崲鎴愪簡澶村瓧娈电殑褰㈠紡锛屽苟涓旂粰杩欎簺鈥滀笉鏄ご瀛楁鐨勫ご瀛楁鈥濊捣浜嗕釜鐗瑰埆鐨勫悕瀛椻€斺€斺€?/span>浼ご瀛楁鈥濓紙pseudo-header fields锛夈€傝€岃捣濮嬭閲岀殑鐗堟湰鍙峰拰閿欒鍘熷洜鐭鍥犱负娌′粈涔堝ぇ鐢紝椤轰究涔熺粰搴熼櫎浜嗐€?/span>
涓轰簡涓庘€滅湡澶村瓧娈碘€濆尯鍒嗗紑鏉ワ紝杩欎簺鈥滀吉澶村瓧娈碘€濅細鍦ㄥ悕瀛楀墠鍔犱竴涓€?鈥濓紝姣斿鈥?authority鈥?鈥?method鈥?鈥?status鈥濓紝鍒嗗埆琛ㄧず鐨勬槸鍩熷悕銆佽姹傛柟娉曞拰鐘舵€佺爜銆?/span>
鐜板湪 HTTP 鎶ユ枃澶村氨绠€鍗曚簡锛屽叏閮芥槸鈥淜ey-Value鈥濆舰寮忕殑瀛楁锛屼簬鏄?HTTP/2 灏变负涓€浜涙渶甯哥敤鐨勫ご瀛楁瀹氫箟浜嗕竴涓彧璇荤殑鈥?/span>闈欐€佽〃鈥濓紙Static Table锛夈€?/span>
涓嬮潰鐨勮繖涓〃鏍煎垪鍑轰簡鈥滈潤鎬佽〃鈥濈殑涓€閮ㄥ垎锛岃繖鏍峰彧瑕佹煡琛ㄥ氨鍙互鐭ラ亾瀛楁鍚嶅拰瀵瑰簲鐨勫€硷紝姣斿鏁板瓧鈥?鈥濅唬琛ㄢ€淕ET鈥濓紝鏁板瓧鈥?鈥濅唬琛ㄧ姸鎬佺爜 200銆?/span>
浣嗗鏋滆〃閲屽彧鏈?Key 娌℃湁 Value锛屾垨鑰呮槸鑷畾涔夊瓧娈垫牴鏈壘涓嶅埌璇ユ€庝箞鍔炲憿锛?/span>
杩欏氨瑕佺敤鍒扳€?/span>鍔ㄦ€佽〃鈥濓紙Dynamic Table锛夛紝瀹冩坊鍔犲湪闈欐€佽〃鍚庨潰锛岀粨鏋勭浉鍚岋紝浣嗕細鍦ㄧ紪鐮佽В鐮佺殑鏃跺€欓殢鏃舵洿鏂般€?/span>
姣斿璇达紝绗竴娆″彂閫佽姹傛椂鐨勨€渦ser-agent鈥濆瓧娈甸暱鏄竴鐧惧涓瓧鑺傦紝鐢ㄥ搱澶浖鍘嬬缉缂栫爜鍙戦€佷箣鍚庯紝瀹㈡埛绔拰鏈嶅姟鍣ㄩ兘鏇存柊鑷繁鐨勫姩鎬佽〃锛屾坊鍔犱竴涓柊鐨勭储寮曞彿鈥?5鈥濄€傞偅涔堜笅涓€娆″彂閫佺殑鏃跺€欏氨涓嶇敤鍐嶉噸澶嶅彂閭d箞澶氬瓧鑺備簡锛屽彧瑕佺敤涓€涓瓧鑺傚彂閫佺紪鍙峰氨濂姐€?/span>
浣犲彲浠ユ兂璞″緱鍑烘潵锛岄殢鐫€鍦?HTTP/2 杩炴帴涓婂彂閫佺殑鎶ユ枃瓒婃潵瓒婂锛屼袱杈圭殑鈥滃瓧鍏糕€濅篃浼氳秺鏉ヨ秺涓板瘜锛屾渶缁堟瘡娆$殑澶撮儴瀛楁閮戒細鍙樻垚涓€涓や釜瀛楄妭鐨勪唬鐮侊紝鍘熸潵涓婂崈瀛楄妭鐨勫ご鐢ㄥ嚑鍗佷釜瀛楄妭灏卞彲浠ヨ〃绀轰簡锛屽帇缂╂晥鏋滄瘮 gzip 瑕佸ソ寰楀銆?/span>
浜岃繘鍒跺抚
澶撮儴鏁版嵁鍘嬬缉涔嬪悗锛孒TTP/2 灏辫鎶婃姤鏂囨媶鎴愪簩杩涘埗鐨勫抚鍑嗗鍙戦€併€?/span>
HTTP/2 鐨勫抚缁撴瀯鏈夌偣绫讳技 TCP 鐨勬鎴栬€?TLS 閲岀殑璁板綍锛屼絾鎶ュご寰堝皬锛屽彧鏈?9 瀛楄妭锛岄潪甯稿湴鑺傜渷锛堝彲浠ュ姣斾竴涓?TCP 澶达紝瀹冩渶灏戞槸 20 涓瓧鑺傦級銆?/span>
浜岃繘鍒剁殑鏍煎紡涔熶繚璇佷簡涓嶄細鏈夋涔夛紝鑰屼笖浣跨敤浣嶈繍绠楄兘澶熼潪甯哥畝鍗曢珮鏁堝湴瑙f瀽銆?/span>
甯у紑澶存槸 3 涓瓧鑺傜殑闀垮害锛堜絾涓嶅寘鎷ご鐨?9 涓瓧鑺傦級锛岄粯璁や笂闄愭槸 2^14锛屾渶澶ф槸 2^24锛屼篃灏辨槸璇?HTTP/2 鐨勫抚閫氬父涓嶈秴杩?16K锛屾渶澶ф槸 16M銆?/span>
闀垮害鍚庨潰鐨勪竴涓瓧鑺傛槸甯х被鍨?/span>锛屽ぇ鑷村彲浠ュ垎鎴?/span>鏁版嵁甯?/span>鍜?/span>鎺у埗甯?/span>涓ょ被锛孒EADERS 甯у拰 DATA 甯у睘浜庢暟鎹抚锛屽瓨鏀剧殑鏄?HTTP 鎶ユ枃锛岃€?SETTINGS銆丳ING銆丳RIORITY 绛夊垯鏄敤鏉ョ鐞嗘祦鐨勬帶鍒跺抚銆?/span>
HTTP/2 鎬诲叡瀹氫箟浜?10 绉嶇被鍨嬬殑甯э紝浣嗕竴涓瓧鑺傚彲浠ヨ〃绀烘渶澶?256 绉嶏紝鎵€浠ヤ篃鍏佽鍦ㄦ爣鍑嗕箣澶栧畾涔夊叾浠栫被鍨嬪疄鐜板姛鑳芥墿灞曘€傝繖灏辨湁鐐瑰儚 TLS 閲屾墿灞曞崗璁殑鎰忔€濅簡锛屾瘮濡?Google 鐨?gRPC 灏卞埄鐢ㄤ簡杩欎釜鐗圭偣锛屽畾涔変簡鍑犵鑷敤鐨勬柊甯х被鍨嬨€?/span>
绗?5 涓瓧鑺傛槸闈炲父閲嶈鐨?/span>甯ф爣蹇?/span>淇℃伅锛屽彲浠ヤ繚瀛?8 涓爣蹇椾綅锛屾惡甯︾畝鍗曠殑鎺у埗淇℃伅銆傚父鐢ㄧ殑鏍囧織浣嶆湁 END_HEADERS 琛ㄧず澶存暟鎹粨鏉燂紝鐩稿綋浜?HTTP/1 閲屽ご鍚庣殑绌鸿锛堚€淺r\n鈥濓級锛?/span>END_STREAM 琛ㄧず鍗曟柟鍚戞暟鎹彂閫佺粨鏉燂紙鍗?EOS锛孍nd of Stream锛夛紝鐩稿綋浜?HTTP/1 閲?Chunked 鍒嗗潡缁撴潫鏍囧織锛堚€?\r\n\r\n鈥濓級銆?/span>
鎶ユ枃澶撮噷鏈€鍚?4 涓瓧鑺傛槸娴佹爣璇嗙锛屼篃灏辨槸甯ф墍灞炵殑鈥滄祦鈥濓紝鎺ユ敹鏂逛娇鐢ㄥ畠灏卞彲浠ヤ粠涔卞簭鐨勫抚閲岃瘑鍒嚭鍏锋湁鐩稿悓娴?ID 鐨勫抚搴忓垪锛屾寜椤哄簭缁勮璧锋潵灏卞疄鐜颁簡铏氭嫙鐨勨€滄祦鈥濄€?/span>
娴佹爣璇嗙铏界劧鏈?4 涓瓧鑺傦紝浣嗘渶楂樹綅琚繚鐣欎笉鐢紝鎵€浠ュ彧鏈?31 浣嶅彲浠ヤ娇鐢紝涔熷氨鏄锛屾祦鏍囪瘑绗︾殑涓婇檺鏄?2^31锛屽ぇ绾︽槸 21 浜裤€?/span>
濂戒簡锛屾妸浜岃繘鍒跺ご鐞嗘竻妤氬悗锛屾垜浠潵鐪嬩竴涓?Wireshark 鎶撳寘鐨勫抚瀹炰緥锛?/span>
鍦ㄨ繖涓抚閲岋紝寮€澶寸殑涓変釜瀛楄妭鏄€?0010a鈥濓紝琛ㄧず鏁版嵁闀垮害鏄?266 瀛楄妭銆?/span>
甯х被鍨嬫槸 1锛岃〃绀?HEADERS 甯э紝璐熻浇锛坧ayload锛夐噷闈㈠瓨鏀剧殑鏄 HPACK 绠楁硶鍘嬬缉鐨勫ご閮ㄤ俊鎭€?/span>
鏍囧織浣嶆槸 0x25锛岃浆鎹㈡垚浜岃繘鍒舵湁 3 涓綅琚疆 1銆侾RIORITY 琛ㄧず璁剧疆浜嗘祦鐨勪紭鍏堢骇锛孍ND_HEADERS 琛ㄧず杩欎竴涓抚灏辨槸瀹屾暣鐨勫ご鏁版嵁锛孍ND_STREAM 琛ㄧず鍗曟柟鍚戞暟鎹彂閫佺粨鏉燂紝鍚庣画鍐嶄笉浼氭湁鏁版嵁甯э紙鍗宠姹傛姤鏂囧畬姣曪紝涓嶄細鍐嶆湁 DATA 甯?/Body 鏁版嵁锛夈€?/span>
鏈€鍚?4 涓瓧鑺傜殑娴佹爣璇嗙鏄暣鏁?1锛岃〃绀鸿繖鏄鎴风鍙戣捣鐨勭涓€涓祦锛屽悗闈㈢殑鍝嶅簲鏁版嵁甯т篃浼氭槸杩欎釜 ID锛屼篃灏辨槸璇村湪 stream[1]閲屽畬鎴愯繖涓姹傚搷搴斻€?/span>
娴佷笌澶氳矾澶嶇敤
寮勬竻妤氫簡甯х粨鏋勫悗鎴戜滑灏辨潵鐪?HTTP/2 鐨勬祦涓庡璺鐢紝瀹冩槸 HTTP/2 鏈€鏍稿績鐨勯儴鍒嗐€?/span>
鍦ㄤ笂涓€璁查噷鎴戠畝鍗曚粙缁嶄簡娴佺殑姒傚康锛屼笉鐭ラ亾浣犫€滄偀鈥濆緱鎬庝箞鏍蜂簡锛熻繖閲屾垜鍐嶉噸澶嶄竴閬嶏細娴佹槸浜岃繘鍒跺抚鐨勫弻鍚戜紶杈撳簭鍒?/span>銆?/span>
瑕佹悶鏄庣櫧娴侊紝鍏抽敭鏄鐞嗚В甯уご閲岀殑娴?ID銆?/span>
鍦?HTTP/2 杩炴帴涓婏紝铏界劧甯ф槸涔卞簭鏀跺彂鐨勶紝浣嗗彧瑕佸畠浠兘鎷ユ湁鐩稿悓鐨勬祦 ID锛屽氨閮藉睘浜庝竴涓祦锛岃€屼笖鍦ㄨ繖涓祦閲屽抚涓嶆槸鏃犲簭鐨勶紝鑰屾槸鏈夌潃涓ユ牸鐨勫厛鍚庨『搴忋€?/span>
姣斿鍦ㄨ繖娆$殑 Wireshark 鎶撳寘閲岋紝灏辨湁鈥?銆?銆?鈥濅竴鍏变笁涓祦锛屽疄闄呬笂灏辨槸鍒嗛厤浜嗕笁涓祦 ID 鍙凤紝鎶婅繖浜涘抚鎸夌紪鍙峰垎缁勶紝鍐嶆帓涓€涓嬮槦锛屽氨鎴愪簡娴併€?/span>
鍦ㄦ蹇典笂锛屼竴涓?HTTP/2 鐨勬祦灏辩瓑鍚屼簬涓€涓?HTTP/1 閲岀殑鈥滆姹?- 搴旂瓟鈥濄€傚湪 HTTP/1 閲屼竴涓€滆姹?- 鍝嶅簲鈥濇姤鏂囨潵鍥炴槸涓€娆?HTTP 閫氫俊锛屽湪 HTTP/2 閲屼竴涓祦涔熸壙杞戒簡鐩稿悓鐨勫姛鑳姐€?/span>
浣犺繕鍙互瀵圭収鐫€ TCP 鏉ョ悊瑙c€俆CP 杩愯鍦?IP 涔嬩笂锛屽叾瀹炰粠 MAC 灞傘€両P 灞傜殑瑙掑害鏉ョ湅锛孴CP 鐨勨€滆繛鎺モ€濇蹇典篃鏄€滆櫄鎷熲€濈殑銆備絾浠庡姛鑳戒笂鐪嬶紝鏃犺鏄?HTTP/2 鐨勬祦锛岃繕鏄?TCP 鐨勮繛鎺ワ紝閮芥槸瀹為檯瀛樺湪鐨勶紝鎵€浠ヤ綘浠ュ悗澶у彲涓嶅繀鍐嶇籂缁撲簬娴佺殑鈥滆櫄鎷熲€濇€э紝鎶婂畠褰撳仛鏄竴涓湡瀹炲瓨鍦ㄧ殑瀹炰綋鏉ョ悊瑙e氨濂姐€?/span>
HTTP/2 鐨勬祦鏈夊摢浜涚壒鐐瑰憿锛熸垜缁欎綘绠€鍗曞垪浜嗕竴涓嬶細
娴佹槸鍙苟鍙戠殑锛屼竴涓?HTTP/2 杩炴帴涓婂彲浠ュ悓鏃跺彂鍑哄涓祦浼犺緭鏁版嵁锛屼篃灏辨槸骞跺彂澶氳姹傦紝瀹炵幇鈥滃璺鐢ㄢ€濓紱
瀹㈡埛绔拰鏈嶅姟鍣ㄩ兘鍙互鍒涘缓娴侊紝鍙屾柟浜掍笉骞叉壈锛?/span>
娴佹槸鍙屽悜鐨勶紝涓€涓祦閲岄潰瀹㈡埛绔拰鏈嶅姟鍣ㄩ兘鍙互鍙戦€佹垨鎺ユ敹鏁版嵁甯э紝涔熷氨鏄竴涓€滆姹?- 搴旂瓟鈥濇潵鍥烇紱
娴佷箣闂存病鏈夊浐瀹氬叧绯伙紝褰兼鐙珛锛屼絾娴佸唴閮ㄧ殑甯ф槸鏈変弗鏍奸『搴忕殑锛?/span>
娴佸彲浠ヨ缃紭鍏堢骇锛岃鏈嶅姟鍣ㄤ紭鍏堝鐞嗭紝姣斿鍏堜紶 HTML/CSS锛屽悗浼犲浘鐗囷紝浼樺寲鐢ㄦ埛浣撻獙锛?/span>
娴?ID 涓嶈兘閲嶇敤锛屽彧鑳介『搴忛€掑锛屽鎴风鍙戣捣鐨?ID 鏄鏁帮紝鏈嶅姟鍣ㄧ鍙戣捣鐨?ID 鏄伓鏁帮紱
鍦ㄦ祦涓婂彂閫佲€淩ST_STREAM鈥濆抚鍙互闅忔椂缁堟娴侊紝鍙栨秷鎺ユ敹鎴栧彂閫侊紱
绗?0 鍙锋祦姣旇緝鐗规畩锛屼笉鑳藉叧闂紝涔熶笉鑳藉彂閫佹暟鎹抚锛屽彧鑳藉彂閫佹帶鍒跺抚锛岀敤浜庢祦閲忔帶鍒躲€?/span>
杩欓噷鎴戝張鐢讳簡涓€寮犲浘锛屾妸涓婃鐨勫浘鐣ユ敼浜嗕竴涓嬶紝鏄剧ず浜嗚繛鎺ヤ腑鏃犲簭鐨勫抚鏄浣曚緷鎹祦 ID 閲嶇粍鎴愭祦鐨勩€?/span>
浠庤繖浜涚壒鎬т腑锛屾垜浠繕鍙互鎺ㄧ悊鍑轰竴浜涙繁灞傛鐨勭煡璇嗙偣銆?/span>
姣斿璇达紝HTTP/2 鍦ㄤ竴涓繛鎺ヤ笂浣跨敤澶氫釜娴佹敹鍙戞暟鎹紝閭d箞瀹冩湰韬粯璁ゅ氨浼氭槸闀胯繛鎺ワ紝鎵€浠ユ案杩滀笉闇€瑕佲€淐onnection鈥濆ご瀛楁锛坘eepalive 鎴?close锛夈€?/span>
浣犲彲浠ュ啀鐪嬩竴涓?Wireshark 鐨勬姄鍖咃紝閲岄潰鍙戦€佷簡涓や釜璇锋眰鈥?31-1鈥濆拰鈥?favicon.ico鈥濓紝濮嬬粓鐢ㄧ殑鏄€?6095<->8443鈥濊繖涓繛鎺ワ紝瀵规瘮涓€涓?/span>绗?8 璁?span data-slate-object="text" data-key="352">锛屼綘灏辫兘澶熺湅鍑哄樊寮備簡銆?/span>
鍙堟瘮濡傦紝涓嬭浇澶ф枃浠剁殑鏃跺€欐兂鍙栨秷鎺ユ敹锛屽湪 HTTP/1 閲屽彧鑳芥柇寮€ TCP 杩炴帴閲嶆柊鈥滀笁娆℃彙鎵嬧€濓紝鎴愭湰寰堥珮锛岃€屽湪 HTTP/2 閲屽氨鍙互绠€鍗曞湴鍙戦€佷竴涓€淩ST_STREAM鈥濅腑鏂祦锛岃€岄暱杩炴帴浼氱户缁繚鎸併€?/span>
鍐嶆瘮濡傦紝鍥犱负瀹㈡埛绔拰鏈嶅姟鍣ㄤ袱绔兘鍙互鍒涘缓娴侊紝鑰屾祦 ID 鏈夊鏁板伓鏁板拰涓婇檺鐨勫尯鍒嗭紝鎵€浠ュぇ澶氭暟鐨勬祦 ID 閮戒細鏄鏁帮紝鑰屼笖瀹㈡埛绔湪涓€涓繛鎺ラ噷鏈€澶氬彧鑳藉彂鍑?2^30锛屼篃灏辨槸 10 浜夸釜璇锋眰銆?/span>
鎵€浠ュ氨瑕侀棶浜嗭細ID 鐢ㄥ畬浜嗚鎬庝箞鍔炲憿锛熻繖涓椂鍊欏彲浠ュ啀鍙戜竴涓帶鍒跺抚鈥淕OAWAY鈥濓紝鐪熸鍏抽棴 TCP 杩炴帴銆?/span>
娴佺姸鎬佽浆鎹?/span>
娴佸緢閲嶈锛屼篃寰堝鏉傘€備负浜嗘洿濂藉湴鎻忚堪杩愯鏈哄埗锛孒TTP/2 鍊熼壌浜?TCP锛屾牴鎹抚鐨勬爣蹇椾綅瀹炵幇娴佺姸鎬佽浆鎹€傚綋鐒讹紝杩欎簺鐘舵€佷篃鏄櫄鎷熺殑锛屽彧鏄负浜嗚緟鍔╃悊瑙c€?/span>
HTTP/2 鐨勬祦涔熸湁涓€涓姸鎬佽浆鎹㈠浘锛岃櫧鐒舵瘮 TCP 瑕佺畝鍗曚竴鐐癸紝浣嗕篃涓嶉偅涔堝ソ鎳傦紝鎵€浠ヤ粖澶╂垜鍙敾浜嗕竴涓畝鍖栫殑鍥撅紝瀵瑰簲鍒颁竴涓爣鍑嗙殑 HTTP鈥滆姹?- 搴旂瓟鈥濄€?/span>
鏈€寮€濮嬬殑鏃跺€欐祦閮芥槸鈥?/span>绌洪棽鈥濓紙idle锛夌姸鎬侊紝涔熷氨鏄€滀笉瀛樺湪鈥濓紝鍙互鐞嗚В鎴愭槸寰呭垎閰嶇殑鈥滃彿娈佃祫婧愨€濄€?/span>
褰撳鎴风鍙戦€?HEADERS 甯у悗锛屾湁浜嗘祦 ID锛屾祦灏辫繘鍏ヤ簡鈥?/span>鎵撳紑鈥濈姸鎬侊紝涓ょ閮藉彲浠ユ敹鍙戞暟鎹紝鐒跺悗瀹㈡埛绔彂閫佷竴涓甫鈥淓ND_STREAM鈥濇爣蹇椾綅鐨勫抚锛屾祦灏辫繘鍏ヤ簡鈥?/span>鍗婂叧闂?/span>鈥濈姸鎬併€?/span>
杩欎釜鈥滃崐鍏抽棴鈥濈姸鎬佸緢閲嶈锛屾剰鍛崇潃瀹㈡埛绔殑璇锋眰鏁版嵁宸茬粡鍙戦€佸畬浜嗭紝闇€瑕佹帴鍙楀搷搴旀暟鎹紝鑰屾湇鍔″櫒绔篃鐭ラ亾璇锋眰鏁版嵁鎺ユ敹瀹屾瘯锛屼箣鍚庡氨瑕佸唴閮ㄥ鐞嗭紝鍐嶅彂閫佸搷搴旀暟鎹€?/span>
鍝嶅簲鏁版嵁鍙戝畬浜嗕箣鍚庯紝涔熻甯︿笂鈥淓ND_STREAM鈥濇爣蹇椾綅锛岃〃绀烘暟鎹彂閫佸畬姣曪紝杩欐牱娴佷袱绔氨閮借繘鍏ヤ簡鈥?/span>鍏抽棴鈥濈姸鎬侊紝娴佸氨缁撴潫浜嗐€?/span>
鍒氭墠涔熻杩囷紝娴?ID 涓嶈兘閲嶇敤锛屾墍浠ユ祦鐨勭敓鍛藉懆鏈熷氨鏄?HTTP/1 閲岀殑涓€娆″畬鏁寸殑鈥滆姹?- 搴旂瓟鈥濓紝娴佸叧闂氨鏄竴娆¢€氫俊缁撴潫銆?/span>
涓嬩竴娆″啀鍙戣姹傚氨瑕佸紑涓€涓柊娴侊紙鑰屼笉鏄柊杩炴帴锛夛紝娴?ID 涓嶆柇澧炲姞锛岀洿鍒板埌杈句笂闄愶紝鍙戦€佲€淕OAWAY鈥濆抚寮€涓€涓柊鐨?TCP 杩炴帴锛屾祦 ID 灏卞張鍙互閲嶅ご璁℃暟銆?/span>
浣犲啀鐪嬬湅杩欏紶鍥撅紝鏄笉鏄拰 HTTP/1 閲岀殑鏍囧噯鈥滆姹?- 搴旂瓟鈥濊繃绋嬪緢鍍忥紝鍙笉杩囪繖鏄彂鐢熷湪铏氭嫙鐨勨€滄祦鈥濅笂锛岃€屼笉鏄疄闄呯殑 TCP 杩炴帴锛屽張鍥犱负娴佸彲浠ュ苟鍙戯紝鎵€浠?HTTP/2 灏卞彲浠ュ疄鐜版棤闃诲鐨勫璺鐢ㄣ€?/span>
灏忕粨
HTTP/2 鐨勫唴瀹瑰疄鍦ㄦ槸澶浜嗭紝涓轰簡鏂逛究瀛︿範锛屾垜鐮嶆帀浜嗕竴浜涚壒鎬э紝姣斿娴佺殑浼樺厛绾с€佷緷璧栧叧绯汇€佹祦閲忔帶鍒剁瓑銆?/span>
浣嗗彧瑕佷綘鎺屾彙浜嗕粖澶╃殑杩欎簺鍐呭锛屼互鍚庡啀鐪?RFC 鏂囨。閮戒笉浼氭湁闅惧害浜嗐€?/span>
HTTP/2 蹇呴』鍏堝彂閫佷竴涓€滆繛鎺ュ墠瑷€鈥濆瓧绗︿覆锛岀劧鍚庢墠鑳藉缓绔嬫寮忚繛鎺ワ紱
HTTP/2 搴熼櫎浜嗚捣濮嬭锛岀粺涓€浣跨敤澶村瓧娈碉紝鍦ㄤ袱绔淮鎶ゅ瓧娈碘€淜ey-Value鈥濈殑绱㈠紩琛紝浣跨敤鈥淗PACK鈥濈畻娉曞帇缂╁ご閮紱
HTTP/2 鎶婃姤鏂囧垏鍒嗕负澶氱绫诲瀷鐨勪簩杩涘埗甯э紝鎶ュご閲屾渶閲嶈鐨勫瓧娈垫槸娴佹爣璇嗙锛屾爣璁板抚灞炰簬鍝釜娴侊紱
娴佹槸 HTTP/2 铏氭嫙鐨勬蹇碉紝鏄抚鐨勫弻鍚戜紶杈撳簭鍒楋紝鐩稿綋浜?HTTP/1 閲岀殑涓€娆♀€滆姹?- 搴旂瓟鈥濓紱
鍦ㄤ竴涓?HTTP/2 杩炴帴涓婂彲浠ュ苟鍙戝涓祦锛屼篃灏辨槸澶氫釜鈥滆姹?- 鍝嶅簲鈥濇姤鏂囷紝杩欏氨鏄€滃璺鐢ㄢ€濄€?/span>
-娣卞叆鍘熺悊-
鐭ュ叾鐒跺苟鐭ュ叾鎵€浠ョ劧
以上是关于HTTP/2鍐呮牳鍓栨瀽的主要内容,如果未能解决你的问题,请参考以下文章
璧垫櫒闆細浠庢枃浠剁郴缁熺殑鏁版嵁缁撴瀯鐪婰inux鍐呮牳璁捐