I'm tryng to use nghttpd server to test HTTP/2.0. To start it i'm using:
nghttpd -v -d ~/Desktop/www 9000 --no-tls
In client terminal, i type:
nghttp -nvu http://127.0.0.1:9000
And i have this output in the client terminal
[ 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
in the server terminal
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
How can i solve this?
nghttpd
does not support upgrade. See this from the author. The client nghttp
has no issues.
You can use nghttpx
, the reverse proxy and your http2 server behind that.
$ 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)=[])