Prefer SPDY/2 for spdy proxy connection

Chrome SPDY/3 flow control does not work well in spdy proxy
connection.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-07-15 21:39:19 +09:00
parent 7f2b9ae75d
commit 06eac680e8
1 changed files with 21 additions and 6 deletions

View File

@ -68,6 +68,18 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
} }
} // namespace } // namespace
namespace {
void set_npn_prefs(unsigned char *out, const char **protos, size_t len)
{
unsigned char *ptr = out;
for(size_t i = 0; i < len; ++i) {
*ptr = strlen(protos[i]);
memcpy(ptr+1, protos[i], *ptr);
ptr += *ptr+1;
}
}
} // namespace
SSL_CTX* create_ssl_context() SSL_CTX* create_ssl_context()
{ {
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
@ -109,12 +121,15 @@ SSL_CTX* create_ssl_context()
verify_callback); verify_callback);
} }
// We speak "http/1.1", "spdy/2" and "spdy/3". // We speak "http/1.1", "spdy/2" and "spdy/3".
proto_list[0] = 6; if(get_config()->spdy_proxy) {
memcpy(&proto_list[1], "spdy/3", 6); // It seems SPDY/3 flow control does not work well in proxy
proto_list[7] = 6; // connection.
memcpy(&proto_list[8], "spdy/2", 6); const char *protos[] = { "spdy/2", "spdy/3", "http/1.1" };
proto_list[14] = 8; set_npn_prefs(proto_list, protos, 3);
memcpy(&proto_list[15], "http/1.1", 8); } else {
const char *protos[] = { "spdy/3", "spdy/2", "http/1.1" };
set_npn_prefs(proto_list, protos, 3);
}
next_proto.first = proto_list; next_proto.first = proto_list;
next_proto.second = sizeof(proto_list); next_proto.second = sizeof(proto_list);