Define NGHTTP2_CLEARTEXT_PROTO_VERSION_ID

This identifier string is used if HTTP/2 is used over cleartext TCP.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-30 21:30:47 +09:00
parent 334658044e
commit 34581d830d
4 changed files with 25 additions and 6 deletions

View File

@ -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

View File

@ -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"

View File

@ -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) {

View File

@ -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")) {