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>

HTTP/2鍐呮牳鍓栨瀽

浣嗗鏋滆〃閲屽彧鏈?Key 娌℃湁 Value锛屾垨鑰呮槸鑷畾涔夊瓧娈垫牴鏈壘涓嶅埌璇ユ€庝箞鍔炲憿锛?/span>

杩欏氨瑕佺敤鍒扳€?/span>鍔ㄦ€佽〃鈥濓紙Dynamic Table锛夛紝瀹冩坊鍔犲湪闈欐€佽〃鍚庨潰锛岀粨鏋勭浉鍚岋紝浣嗕細鍦ㄧ紪鐮佽В鐮佺殑鏃跺€欓殢鏃舵洿鏂般€?/span>

姣斿璇达紝绗竴娆″彂閫佽姹傛椂鐨勨€渦ser-agent鈥濆瓧娈甸暱鏄竴鐧惧涓瓧鑺傦紝鐢ㄥ搱澶浖鍘嬬缉缂栫爜鍙戦€佷箣鍚庯紝瀹㈡埛绔拰鏈嶅姟鍣ㄩ兘鏇存柊鑷繁鐨勫姩鎬佽〃锛屾坊鍔犱竴涓柊鐨勭储寮曞彿鈥?5鈥濄€傞偅涔堜笅涓€娆″彂閫佺殑鏃跺€欏氨涓嶇敤鍐嶉噸澶嶅彂閭d箞澶氬瓧鑺備簡锛屽彧瑕佺敤涓€涓瓧鑺傚彂閫佺紪鍙峰氨濂姐€?/span>

HTTP/2鍐呮牳鍓栨瀽

浣犲彲浠ユ兂璞″緱鍑烘潵锛岄殢鐫€鍦?HTTP/2 杩炴帴涓婂彂閫佺殑鎶ユ枃瓒婃潵瓒婂锛屼袱杈圭殑鈥滃瓧鍏糕€濅篃浼氳秺鏉ヨ秺涓板瘜锛屾渶缁堟瘡娆$殑澶撮儴瀛楁閮戒細鍙樻垚涓€涓や釜瀛楄妭鐨勪唬鐮侊紝鍘熸潵涓婂崈瀛楄妭鐨勫ご鐢ㄥ嚑鍗佷釜瀛楄妭灏卞彲浠ヨ〃绀轰簡锛屽帇缂╂晥鏋滄瘮 gzip 瑕佸ソ寰楀銆?/span>


浜岃繘鍒跺抚

澶撮儴鏁版嵁鍘嬬缉涔嬪悗锛孒TTP/2 灏辫鎶婃姤鏂囨媶鎴愪簩杩涘埗鐨勫抚鍑嗗鍙戦€併€?/span>

HTTP/2 鐨勫抚缁撴瀯鏈夌偣绫讳技 TCP 鐨勬鎴栬€?TLS 閲岀殑璁板綍锛屼絾鎶ュご寰堝皬锛屽彧鏈?9 瀛楄妭锛岄潪甯稿湴鑺傜渷锛堝彲浠ュ姣斾竴涓?TCP 澶达紝瀹冩渶灏戞槸 20 涓瓧鑺傦級銆?/span>

浜岃繘鍒剁殑鏍煎紡涔熶繚璇佷簡涓嶄細鏈夋涔夛紝鑰屼笖浣跨敤浣嶈繍绠楄兘澶熼潪甯哥畝鍗曢珮鏁堝湴瑙f瀽銆?/span>

HTTP/2鍐呮牳鍓栨瀽

甯у紑澶存槸 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>

HTTP/2鍐呮牳鍓栨瀽

鍦ㄨ繖涓抚閲岋紝寮€澶寸殑涓変釜瀛楄妭鏄€?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/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>

HTTP/2鍐呮牳鍓栨瀽

浠庤繖浜涚壒鎬т腑锛屾垜浠繕鍙互鎺ㄧ悊鍑轰竴浜涙繁灞傛鐨勭煡璇嗙偣銆?/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>

HTTP/2鍐呮牳鍓栨瀽

鏈€寮€濮嬬殑鏃跺€欐祦閮芥槸鈥?/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鍐呮牳鍓栨瀽



以上是关于HTTP/2鍐呮牳鍓栨瀽的主要内容,如果未能解决你的问题,请参考以下文章

鍐呮牳妯″潡鍙傛暟璁捐

璧垫櫒闆細浠庢枃浠剁郴缁熺殑鏁版嵁缁撴瀯鐪婰inux鍐呮牳璁捐

ASP.NET Core绠¢亾娣卞害鍓栨瀽锛?锛夛細绠¢亾鏄浣曞鐞咹TTP璇锋眰鐨勶紵

NT 鍐呮牳鍑芥暟鍘熷瀷澶у叏

Linux鍔ㄦ€佷负鍐呮牳娣诲姞鏂扮殑绯荤粺璋冪敤

鎿嶄綔绯荤粺-鎿嶄綔绯荤粺-鍐呮牳涓殑灞忓箷鎵撳嵃(涓?