http2 客户端无法解析 HTTP 升级响应 header
http2 client failed to parse HTTP Upgrade response header
我正在尝试使用 nghttpd 服务器来测试 HTTP/2.0。要启动它,我正在使用:
nghttpd -v -d ~/Desktop/www 9000 --no-tls
在客户端,我输入:
nghttp -nvu http://127.0.0.1:9000
我在客户端有这个输出
[ 0.000] Connected
[ 0.000] HTTP Upgrade request
GET / HTTP/1.1
host: 127.0.0.1:9000
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.35.1
[ERROR] Failed to parse HTTP Upgrade response header:
(HPE_INVALID_CONSTANT) invalid constant string
Some requests were not processed. total=1, processed=0
在服务器端
IPv6: listen :::9000
IPv4: listen 0.0.0.0:9000
[id=1] [ 5.803] send SETTINGS frame <length=6, flags=0x00, stream_id=0>
(niv=1)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[id=1] [ 5.803] closed
我该如何解决这个问题?
nghttpd
不支持升级。参见作者的this。客户端 nghttp
没有问题。
您可以使用 nghttpx
、反向代理和您的 http2 服务器。
$ nghttp -nvu http://nghttp2.org/
[ 1.104] Connected
[ 1.104] HTTP Upgrade request
GET / HTTP/1.1
host: nghttp2.org
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.30.0
[ 1.327] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c
[ 1.327] HTTP Upgrade success
[ 1.327] recv SETTINGS frame <length=24, flags=0x00, stream_id=0>
(niv=4)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):1048576]
[UNKNOWN(0x08):1]
[SETTINGS_HEADER_TABLE_SIZE(0x01):8192]
[ 1.327] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 1.327] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
(dep_stream_id=11, weight=16, exclusive=0)
[ 1.332] recv (stream_id=1) :status: 200
[ 1.332] recv (stream_id=1) date: Mon, 17 Dec 2018 01:37:07 GMT
[ 1.332] recv (stream_id=1) content-type: text/html
[ 1.332] recv (stream_id=1) last-modified: Sun, 09 Dec 2018 15:35:09 GMT
[ 1.332] recv (stream_id=1) etag: "5c0d362d-19d8"
[ 1.332] recv (stream_id=1) accept-ranges: bytes
[ 1.332] recv (stream_id=1) content-length: 6616
[ 1.332] recv (stream_id=1) x-backend-header-rtt: 0.008122
[ 1.332] recv (stream_id=1) server: nghttpx
[ 1.332] recv (stream_id=1) via: 2 nghttpx
[ 1.332] recv (stream_id=1) x-frame-options: SAMEORIGIN
[ 1.332] recv (stream_id=1) x-xss-protection: 1; mode=block
[ 1.332] recv (stream_id=1) x-content-type-options: nosniff
[ 1.332] recv HEADERS frame <length=198, flags=0x04, stream_id=1>
; END_HEADERS
(padlen=0)
; First response header
[ 1.366] recv DATA frame <length=6616, flags=0x01, stream_id=1>
; END_STREAM
[ 1.366] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
根据上面的回答。我做这个
http2 服务器
nghttpd -v -d /Desktop/www --no-tls -a 127.0.0.1 9000
反向代理
nghttpx -b '127.0.0.1,9000;;proto=h2' -f '127.0.0.1,9001;no-tls' -L INFO -o
http2 客户端
nghttp -v http://127.0.0.1:9001/index.html
我正在尝试使用 nghttpd 服务器来测试 HTTP/2.0。要启动它,我正在使用:
nghttpd -v -d ~/Desktop/www 9000 --no-tls
在客户端,我输入:
nghttp -nvu http://127.0.0.1:9000
我在客户端有这个输出
[ 0.000] Connected
[ 0.000] HTTP Upgrade request
GET / HTTP/1.1
host: 127.0.0.1:9000
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.35.1
[ERROR] Failed to parse HTTP Upgrade response header:
(HPE_INVALID_CONSTANT) invalid constant string
Some requests were not processed. total=1, processed=0
在服务器端
IPv6: listen :::9000
IPv4: listen 0.0.0.0:9000
[id=1] [ 5.803] send SETTINGS frame <length=6, flags=0x00, stream_id=0>
(niv=1)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[id=1] [ 5.803] closed
我该如何解决这个问题?
nghttpd
不支持升级。参见作者的this。客户端 nghttp
没有问题。
您可以使用 nghttpx
、反向代理和您的 http2 服务器。
$ nghttp -nvu http://nghttp2.org/
[ 1.104] Connected
[ 1.104] HTTP Upgrade request
GET / HTTP/1.1
host: nghttp2.org
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.30.0
[ 1.327] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c
[ 1.327] HTTP Upgrade success
[ 1.327] recv SETTINGS frame <length=24, flags=0x00, stream_id=0>
(niv=4)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):1048576]
[UNKNOWN(0x08):1]
[SETTINGS_HEADER_TABLE_SIZE(0x01):8192]
[ 1.327] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 1.327] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 1.327] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
(dep_stream_id=11, weight=16, exclusive=0)
[ 1.332] recv (stream_id=1) :status: 200
[ 1.332] recv (stream_id=1) date: Mon, 17 Dec 2018 01:37:07 GMT
[ 1.332] recv (stream_id=1) content-type: text/html
[ 1.332] recv (stream_id=1) last-modified: Sun, 09 Dec 2018 15:35:09 GMT
[ 1.332] recv (stream_id=1) etag: "5c0d362d-19d8"
[ 1.332] recv (stream_id=1) accept-ranges: bytes
[ 1.332] recv (stream_id=1) content-length: 6616
[ 1.332] recv (stream_id=1) x-backend-header-rtt: 0.008122
[ 1.332] recv (stream_id=1) server: nghttpx
[ 1.332] recv (stream_id=1) via: 2 nghttpx
[ 1.332] recv (stream_id=1) x-frame-options: SAMEORIGIN
[ 1.332] recv (stream_id=1) x-xss-protection: 1; mode=block
[ 1.332] recv (stream_id=1) x-content-type-options: nosniff
[ 1.332] recv HEADERS frame <length=198, flags=0x04, stream_id=1>
; END_HEADERS
(padlen=0)
; First response header
[ 1.366] recv DATA frame <length=6616, flags=0x01, stream_id=1>
; END_STREAM
[ 1.366] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
根据上面的回答。我做这个
http2 服务器
nghttpd -v -d /Desktop/www --no-tls -a 127.0.0.1 9000
反向代理
nghttpx -b '127.0.0.1,9000;;proto=h2' -f '127.0.0.1,9001;no-tls' -L INFO -o
http2 客户端
nghttp -v http://127.0.0.1:9001/index.html