Commit 34581d83 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID

This identifier string is used if HTTP/2 is used over cleartext TCP.
parent 33465804
......@@ -38,7 +38,8 @@ extern "C" {
/**
* @macro
*
* The protocol version identification of this library supports.
* The protocol version identification string of this library
* supports. This identifier is used if HTTP/2 is used over TLS.
*/
#define NGHTTP2_PROTO_VERSION_ID "h2-10"
/**
......@@ -48,6 +49,22 @@ extern "C" {
*/
#define NGHTTP2_PROTO_VERSION_ID_LEN 5
/**
* @macro
*
* The protocol version identification string of this library
* supports. This identifier is used if HTTP/2 is used over cleartext
* TCP.
*/
#define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "h2c-10"
/**
* @macro
*
* The length of :macro:`NGHTTP2_CLEARTEXT_PROTO_VERSION_ID`.
*/
#define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID_LEN 6
struct nghttp2_session;
/**
* @struct
......
......@@ -611,7 +611,7 @@ struct HttpClient {
req += hostport;
req += "\r\n"
"Connection: Upgrade, HTTP2-Settings\r\n"
"Upgrade: " NGHTTP2_PROTO_VERSION_ID "\r\n"
"Upgrade: " NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "\r\n"
"HTTP2-Settings: ";
req += token68;
req += "\r\n"
......
......@@ -542,7 +542,7 @@ int ClientHandler::perform_http2_upgrade(HttpsUpstream *http)
set_bev_cb(upstream_http2_connhd_readcb, upstream_writecb, upstream_eventcb);
static char res[] = "HTTP/1.1 101 Switching Protocols\r\n"
"Connection: Upgrade\r\n"
"Upgrade: " NGHTTP2_PROTO_VERSION_ID "\r\n"
"Upgrade: " NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "\r\n"
"\r\n";
rv = bufferevent_write(bev_, res, sizeof(res) - 1);
if(rv != 0) {
......
......@@ -734,10 +734,12 @@ bool Downstream::http2_upgrade_request() const
bool upgrade_seen = false;
bool http2_settings_seen = false;
for(auto& hd : request_headers_) {
// For now just check NGHTTP2_PROTO_VERSION_ID in Upgrade header
// field and existence of HTTP2-Settings header field.
// For now just check NGHTTP2_CLEARTEXT_PROTO_VERSION_ID in
// Upgrade header field and existence of HTTP2-Settings header
// field.
if(util::strieq(hd.first.c_str(), "upgrade")) {
if(util::strieq(hd.second.c_str(), NGHTTP2_PROTO_VERSION_ID)) {
if(util::strieq(hd.second.c_str(),
NGHTTP2_CLEARTEXT_PROTO_VERSION_ID)) {
upgrade_seen = true;
}
} else if(util::strieq(hd.first.c_str(), "http2-settings")) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment