Define HTTP/2.0 protocol version ID

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-26 01:38:04 +09:00
parent 9c54e63871
commit 459a269049
3 changed files with 8 additions and 3 deletions

View File

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

View File

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

View File

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