New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade fails when server omits reason phrase #949

rschmitt opened this Issue Jun 25, 2017 · 1 comment


None yet
2 participants

rschmitt commented Jun 25, 2017

Invoking nghttp with the --upgrade flag does not work if the server omits the optional reason-phrase from the status-line. (This is the default behavior of Tomcat starting with 8.5. Tomcat 9.0 cannot be configured to send the reason-phrase at all.) For example:

 ~ $ nghttp --no-dep -v 'http://[::1]:8080/' -u
[  0.000] Connected
[  0.000] HTTP Upgrade request
GET / HTTP/1.1
host: [::1]:8080
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.23.1

[  0.001] HTTP Upgrade response
HTTP/1.1 101
Connection: Upgrade
Upgrade: h2c
Date: Sun, 25 Jun 2017 19:06:41 GMT

[ERROR] HTTP Upgrade failed
Some requests were not processed. total=1, processed=0

The omission of the Switching Protocols text breaks nghttp2's request parsing in such a way that it thinks the Upgrade request failed. The root cause is in third-party/http-parser/http_parser.c: skipping the reason-phrase causes the s_res_status parser state to be skipped, which in turn means that the on_status callback (namely htp_statuscb) never fires, which means that upgrade_response_status_code is never set; any status code other than 101 is (reasonably) interpreted as failure:

  if (upgrade_response_status_code != 101) {
    std::cerr << "[ERROR] HTTP Upgrade failed; status was " << upgrade_response_status_code << std::endl;

    return -1;

This comment has been minimized.

Show comment
Hide comment

tatsuhiro-t Jun 27, 2017


Thank you for telling me. #950 fixes this issue.


tatsuhiro-t commented Jun 27, 2017

Thank you for telling me. #950 fixes this issue.

@tatsuhiro-t tatsuhiro-t added this to the v1.24.0 milestone Jun 27, 2017

@tatsuhiro-t tatsuhiro-t closed this in #950 Jun 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment