From: Stefan Eissing Date: Mon, 14 Sep 2015 12:26:18 +0000 (+0000) Subject: changing r->protocol to HTTP/2 for all directly handles requests, fixing handling... X-Git-Tag: 2.5.0-alpha~2848 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8562b60d81df9a1e1ff88f2b66387c9e3c6accbe;p=thirdparty%2Fapache%2Fhttpd.git changing r->protocol to HTTP/2 for all directly handles requests, fixing handling of H2SerializeHeader config to have an effect git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1702919 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_config.c b/modules/http2/h2_config.c index 883f273a38f..a370bd620c3 100644 --- a/modules/http2/h2_config.c +++ b/modules/http2/h2_config.c @@ -372,41 +372,11 @@ h2_config *h2_config_rget(request_rec *r) h2_config *h2_config_get(conn_rec *c) { h2_ctx *ctx = h2_ctx_get(c); + if (ctx->config) { return ctx->config; } - if (!ctx->server && ctx->hostname) { - /* We have a host agreed upon via TLS SNI, but no request yet. - * The sni host was accepted and therefore does match a server record - * (vhost) for it. But we need to know which one. - * Normally, it is enough to be set on the initial request on a - * connection, but we need it earlier. Simulate a request and call - * the vhost matching stuff. - */ - apr_uri_t uri; - request_rec r; - memset(&uri, 0, sizeof(uri)); - uri.scheme = (char*)"https"; - uri.hostinfo = (char*)ctx->hostname; - uri.hostname = (char*)ctx->hostname; - uri.port_str = (char*)""; - uri.port = c->local_addr->port; - uri.path = (char*)"/"; - - memset(&r, 0, sizeof(r)); - r.uri = (char*)"/"; - r.connection = c; - r.pool = c->pool; - r.hostname = ctx->hostname; - r.headers_in = apr_table_make(c->pool, 1); - r.parsed_uri = uri; - r.status = HTTP_OK; - r.server = r.connection->base_server; - ap_update_vhost_from_headers(&r); - ctx->server = r.server; - } - - if (ctx->server) { + else if (ctx->server) { ctx->config = h2_config_sget(ctx->server); return ctx->config; } diff --git a/modules/http2/h2_ctx.c b/modules/http2/h2_ctx.c index 0e198456f23..f37a1474a1e 100644 --- a/modules/http2/h2_ctx.c +++ b/modules/http2/h2_ctx.c @@ -68,6 +68,12 @@ h2_ctx *h2_ctx_protocol_set(h2_ctx *ctx, const char *proto) return ctx; } +h2_ctx *h2_ctx_server_set(h2_ctx *ctx, server_rec *s) +{ + ctx->server = s; + return ctx; +} + int h2_ctx_is_task(h2_ctx *ctx) { return ctx && !!ctx->task_env; diff --git a/modules/http2/h2_ctx.h b/modules/http2/h2_ctx.h index f9bc8278296..86c59206eda 100644 --- a/modules/http2/h2_ctx.h +++ b/modules/http2/h2_ctx.h @@ -46,6 +46,10 @@ h2_ctx *h2_ctx_create_for(const conn_rec *c, struct h2_task_env *env); */ h2_ctx *h2_ctx_protocol_set(h2_ctx *ctx, const char *proto); +/* Set the server_rec relevant for this context. + */ +h2_ctx *h2_ctx_server_set(h2_ctx *ctx, server_rec *s); + /** * Get the h2 protocol negotiated for this connection, or NULL. */ diff --git a/modules/http2/h2_switch.c b/modules/http2/h2_switch.c index 4cdc4118b0a..23c34490eaa 100644 --- a/modules/http2/h2_switch.c +++ b/modules/http2/h2_switch.c @@ -141,6 +141,7 @@ static int h2_protocol_switch(conn_rec *c, request_rec *r, server_rec *s, ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "switching protocol to '%s'", protocol); h2_ctx_protocol_set(ctx, protocol); + h2_ctx_server_set(ctx, s); if (r != NULL) { apr_status_t status; diff --git a/modules/http2/h2_task.c b/modules/http2/h2_task.c index 26b8c6e40e8..bbea7b20f8a 100644 --- a/modules/http2/h2_task.c +++ b/modules/http2/h2_task.c @@ -220,7 +220,7 @@ apr_status_t h2_task_do(h2_task *task, h2_worker *worker) task->mplx = NULL; env.input_eos = task->input_eos; - env.serialize_headers = !!h2_config_geti(cfg, H2_CONF_SER_HEADERS); + env.serialize_headers = h2_config_geti(cfg, H2_CONF_SER_HEADERS); /* Create a subpool from the worker one to be used for all things * with life-time of this task_env execution. @@ -389,8 +389,8 @@ static request_rec *h2_task_create_request(h2_task_env *env) } ap_parse_uri(r, env->path); - r->protocol = (char*)"HTTP/1.1"; - r->proto_num = HTTP_VERSION(1, 1); + r->protocol = (char*)"HTTP/2"; + r->proto_num = HTTP_VERSION(2, 0); /* update what we think the virtual host is based on the headers we've * now read. may update status. diff --git a/modules/http2/h2_task_input.c b/modules/http2/h2_task_input.c index cc7d8503fd5..487f7e60692 100644 --- a/modules/http2/h2_task_input.c +++ b/modules/http2/h2_task_input.c @@ -51,6 +51,9 @@ h2_task_input *h2_task_input_create(h2_task_env *env, apr_pool_t *pool, input->bb = NULL; if (env->serialize_headers) { + ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, &env->c, + "h2_task_input(%s): serialize request %s %s", + env->id, env->method, env->path); input->bb = apr_brigade_create(pool, bucket_alloc); apr_brigade_printf(input->bb, NULL, NULL, "%s %s HTTP/1.1\r\n", env->method, env->path);