From: Stefan Eissing Date: Fri, 22 Jan 2016 10:09:28 +0000 (+0000) Subject: expr support for HTTP2 variable X-Git-Tag: 2.5.0-alpha~2311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44026b36fa9fe6a521673eb0d17eb4478a47fc7c;p=thirdparty%2Fapache%2Fhttpd.git expr support for HTTP2 variable git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726167 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 036e3e0b362..f73f06c4b66 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) ap_expr: expression support for variable HTTP2=on|off + [Stefan Eissing] + *) mod_status/scoreboard: showing connection protocol in new column, new ap_update_child_status methods for updating server/description. mod_ssl sets vhost negotiated by servername directly. diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index 257eb1d9a4c..e6931be8b2c 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -270,6 +270,9 @@ listfunction ::= listfuncname "(" word ")" HANDLER The name of the handler creating the response + HTTP2 + "on" if the request uses http/2, + "off" otherwise HTTPS "on" if the request uses https, "off" otherwise diff --git a/modules/http2/mod_http2.c b/modules/http2/mod_http2.c index 06b0b7799ac..809a8832765 100644 --- a/modules/http2/mod_http2.c +++ b/modules/http2/mod_http2.c @@ -132,8 +132,6 @@ static void h2_child_init(apr_pool_t *pool, server_rec *s) APLOGNO(02949) "initializing connection handling"); } - APR_REGISTER_OPTIONAL_FN(http2_is_h2); - APR_REGISTER_OPTIONAL_FN(http2_var_lookup); } /* Install this module into the apache2 infrastructure. @@ -142,6 +140,9 @@ static void h2_hooks(apr_pool_t *pool) { static const char *const mod_ssl[] = { "mod_ssl.c", NULL}; + APR_REGISTER_OPTIONAL_FN(http2_is_h2); + APR_REGISTER_OPTIONAL_FN(http2_var_lookup); + ap_log_perror(APLOG_MARK, APLOG_TRACE1, 0, pool, "installing hooks"); /* Run once after configuration is set, but before mpm children initialize. diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 5a8f207eadc..d8428ed98a3 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -1370,11 +1370,15 @@ static int op_file_subr(ap_expr_eval_ctx_t *ctx, const void *data, const char *a APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *)); static APR_OPTIONAL_FN_TYPE(ssl_is_https) *is_https = NULL; +APR_DECLARE_OPTIONAL_FN(int, http2_is_h2, (conn_rec *)); +static APR_OPTIONAL_FN_TYPE(http2_is_h2) *is_http2 = NULL; + static const char *conn_var_names[] = { "HTTPS", /* 0 */ "IPV6", /* 1 */ "CONN_LOG_ID", /* 2 */ "CONN_REMOTE_ADDR", /* 3 */ + "HTTP2", /* 4 */ NULL }; @@ -1408,6 +1412,11 @@ static const char *conn_var_fn(ap_expr_eval_ctx_t *ctx, const void *data) return c->log_id; case 3: return c->client_ip; + case 4: + if (is_http2 && is_http2(c)) + return "on"; + else + return "off"; default: ap_assert(0); return NULL; @@ -1927,6 +1936,7 @@ static int ap_expr_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https); + is_http2 = APR_RETRIEVE_OPTIONAL_FN(http2_is_h2); apr_pool_cleanup_register(pconf, &is_https, ap_pool_cleanup_set_null, apr_pool_cleanup_null); return OK;