nghttpx: Add --http2-no-cookie-crumbling option

This commit is contained in:
Tatsuhiro Tsujikawa 2013-11-18 00:03:55 +09:00
parent faedc4381d
commit 53b3fba05b
4 changed files with 17 additions and 1 deletions

View File

@ -422,6 +422,7 @@ void fill_default_config()
mod_config()->client_cert_file = nullptr; mod_config()->client_cert_file = nullptr;
mod_config()->http2_upstream_dump_request_header = nullptr; mod_config()->http2_upstream_dump_request_header = nullptr;
mod_config()->http2_upstream_dump_response_header = nullptr; mod_config()->http2_upstream_dump_response_header = nullptr;
mod_config()->http2_no_cookie_crumbling = false;
} }
} // namespace } // namespace
@ -630,6 +631,8 @@ void print_help(std::ostream& out)
<< " Default: " << " Default: "
<< get_config()->http2_downstream_window_bits << "\n" << get_config()->http2_downstream_window_bits << "\n"
<< " --backend-no-tls Disable SSL/TLS on backend connections.\n" << " --backend-no-tls Disable SSL/TLS on backend connections.\n"
<< " --http2-no-cookie-crumbling\n"
<< " Don't crumble cookie header field.\n"
<< "\n" << "\n"
<< " Mode:\n" << " Mode:\n"
<< " (default mode) Accept HTTP/2.0, SPDY and HTTP/1.1 over\n" << " (default mode) Accept HTTP/2.0, SPDY and HTTP/1.1 over\n"
@ -770,6 +773,7 @@ int main(int argc, char **argv)
{"client-cert-file", required_argument, &flag, 42}, {"client-cert-file", required_argument, &flag, 42},
{"frontend-http2-dump-request-header", required_argument, &flag, 43}, {"frontend-http2-dump-request-header", required_argument, &flag, 43},
{"frontend-http2-dump-response-header", required_argument, &flag, 44}, {"frontend-http2-dump-response-header", required_argument, &flag, 44},
{"http2-no-cookie-crumbling", no_argument, &flag, 45},
{nullptr, 0, nullptr, 0 } {nullptr, 0, nullptr, 0 }
}; };
@ -1004,6 +1008,11 @@ int main(int argc, char **argv)
(SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER, (SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER,
optarg)); optarg));
break; break;
case 45:
// --http2-no-cookie-crumbling
cmdcfgs.push_back(std::make_pair
(SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING, "yes"));
break;
default: default:
break; break;
} }

View File

@ -109,6 +109,7 @@ const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER[] =
"frontend-http2-dump-request-header"; "frontend-http2-dump-request-header";
const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER[] = const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER[] =
"frontend-http2-dump-response-header"; "frontend-http2-dump-response-header";
const char SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING[] = "http2-no-cookie-crumbling";
namespace { namespace {
Config *config = nullptr; Config *config = nullptr;
@ -447,6 +448,8 @@ int parse_config(const char *opt, const char *optarg)
return -1; return -1;
} }
mod_config()->http2_upstream_dump_response_header = f; mod_config()->http2_upstream_dump_response_header = f;
} else if(util::strieq(opt, SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING)) {
mod_config()->http2_no_cookie_crumbling = util::strieq(optarg, "yes");
} else if(util::strieq(opt, "conf")) { } else if(util::strieq(opt, "conf")) {
LOG(WARNING) << "conf is ignored"; LOG(WARNING) << "conf is ignored";
} else { } else {

View File

@ -98,6 +98,7 @@ extern const char SHRPX_OPT_CLIENT_PRIVATE_KEY_FILE[];
extern const char SHRPX_OPT_CLIENT_CERT_FILE[]; extern const char SHRPX_OPT_CLIENT_CERT_FILE[];
extern const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER[]; extern const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER[];
extern const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER[]; extern const char SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER[];
extern const char SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING[];
union sockaddr_union { union sockaddr_union {
sockaddr sa; sockaddr sa;
@ -200,6 +201,7 @@ struct Config {
char *client_cert_file; char *client_cert_file;
FILE *http2_upstream_dump_request_header; FILE *http2_upstream_dump_request_header;
FILE *http2_upstream_dump_response_header; FILE *http2_upstream_dump_response_header;
bool http2_no_cookie_crumbling;
}; };
const Config* get_config(); const Config* get_config();

View File

@ -228,7 +228,9 @@ int Http2DownstreamConnection::push_request_headers()
return 0; return 0;
} }
size_t nheader = downstream_->get_request_headers().size(); size_t nheader = downstream_->get_request_headers().size();
downstream_->crumble_request_cookie(); if(!get_config()->http2_no_cookie_crumbling) {
downstream_->crumble_request_cookie();
}
downstream_->normalize_request_headers(); downstream_->normalize_request_headers();
auto end_headers = std::end(downstream_->get_request_headers()); auto end_headers = std::end(downstream_->get_request_headers());
// 12 means: // 12 means: