1
0
mirror of https://github.com/apache/httpd.git synced 2025-11-22 21:22:39 +03:00

expr support for HTTP2 variable

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stefan Eissing
2016-01-22 10:09:28 +00:00
parent 736508c43b
commit 44026b36fa
4 changed files with 19 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
-*- coding: utf-8 -*- -*- coding: utf-8 -*-
Changes with Apache 2.5.0 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 *) mod_status/scoreboard: showing connection protocol in new column, new
ap_update_child_status methods for updating server/description. mod_ssl ap_update_child_status methods for updating server/description. mod_ssl
sets vhost negotiated by servername directly. sets vhost negotiated by servername directly.

View File

@@ -270,6 +270,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
<tr><td><code>HANDLER</code></td> <tr><td><code>HANDLER</code></td>
<td>The name of the <a href="handler.html">handler</a> creating <td>The name of the <a href="handler.html">handler</a> creating
the response</td></tr> the response</td></tr>
<tr><td><code>HTTP2</code></td>
<td>"<code>on</code>" if the request uses http/2,
"<code>off</code>" otherwise</td></tr>
<tr><td><code>HTTPS</code></td> <tr><td><code>HTTPS</code></td>
<td>"<code>on</code>" if the request uses https, <td>"<code>on</code>" if the request uses https,
"<code>off</code>" otherwise</td></tr> "<code>off</code>" otherwise</td></tr>

View File

@@ -132,8 +132,6 @@ static void h2_child_init(apr_pool_t *pool, server_rec *s)
APLOGNO(02949) "initializing connection handling"); 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. /* 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}; 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"); ap_log_perror(APLOG_MARK, APLOG_TRACE1, 0, pool, "installing hooks");
/* Run once after configuration is set, but before mpm children initialize. /* Run once after configuration is set, but before mpm children initialize.

View File

@@ -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 *)); APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
static APR_OPTIONAL_FN_TYPE(ssl_is_https) *is_https = NULL; 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[] = { static const char *conn_var_names[] = {
"HTTPS", /* 0 */ "HTTPS", /* 0 */
"IPV6", /* 1 */ "IPV6", /* 1 */
"CONN_LOG_ID", /* 2 */ "CONN_LOG_ID", /* 2 */
"CONN_REMOTE_ADDR", /* 3 */ "CONN_REMOTE_ADDR", /* 3 */
"HTTP2", /* 4 */
NULL NULL
}; };
@@ -1408,6 +1412,11 @@ static const char *conn_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
return c->log_id; return c->log_id;
case 3: case 3:
return c->client_ip; return c->client_ip;
case 4:
if (is_http2 && is_http2(c))
return "on";
else
return "off";
default: default:
ap_assert(0); ap_assert(0);
return NULL; 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) apr_pool_t *ptemp, server_rec *s)
{ {
is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https); 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_register(pconf, &is_https, ap_pool_cleanup_set_null,
apr_pool_cleanup_null); apr_pool_cleanup_null);
return OK; return OK;