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;
}
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;
*/
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.
*/
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;
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.
}
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.
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);