Клиенту http2 не удалось разобрать заголовок ответа HTTP Upgrade - PullRequest
0 голосов
/ 16 декабря 2018

Я пытаюсь использовать сервер 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

Как я могу решить эту проблему?

Ответы [ 2 ]

0 голосов
/ 18 декабря 2018

Согласно ответу выше.я делаю это

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
0 голосов
/ 17 декабря 2018

nghttpd не поддерживает обновление.См. это от автора.У клиента 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)=[])
...