Commit 459a2690 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Define HTTP/2.0 protocol version ID

parent 9c54e638
......@@ -35,6 +35,9 @@ extern "C" {
#include <nghttp2/nghttp2ver.h>
#define NGHTTP2_PROTO_VERSION_ID "HTTP-draft-04/2.0"
#define NGHTTP2_PROTO_VERSION_ID_LEN 17
struct nghttp2_session;
/**
* @struct
......
......@@ -32,7 +32,8 @@ int nghttp2_select_next_protocol(unsigned char **out, unsigned char *outlen,
int http_selected = 0;
unsigned int i = 0;
for(; i < inlen; i += in[i]+1) {
if(in[i] == 17 && memcmp(&in[i+1], "HTTP-draft-04/2.0", in[i]) == 0) {
if(in[i] == NGHTTP2_PROTO_VERSION_ID_LEN &&
memcmp(&in[i+1], NGHTTP2_PROTO_VERSION_ID, in[i]) == 0) {
*out = (unsigned char*)&in[i+1];
*outlen = in[i];
return 1;
......
......@@ -365,7 +365,7 @@ int Http2Handler::verify_npn_result()
if(sessions_->get_config()->verbose) {
std::cout << "The negotiated next protocol: " << proto << std::endl;
}
if(proto == "HTTP-draft-04/2.0") {
if(proto == NGHTTP2_PROTO_VERSION_ID) {
return 0;
}
}
......@@ -1003,7 +1003,8 @@ int HttpServer::run()
}
proto_list[0] = 17;
memcpy(&proto_list[1], "HTTP-draft-04/2.0", 17);
memcpy(&proto_list[1], NGHTTP2_PROTO_VERSION_ID,
NGHTTP2_PROTO_VERSION_ID_LEN);
next_proto.first = proto_list;
next_proto.second = 18;
......
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