]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
expr support for HTTP2 variable
authorStefan Eissing <icing@apache.org>
Fri, 22 Jan 2016 10:09:28 +0000 (10:09 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 22 Jan 2016 10:09:28 +0000 (10:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726167 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/expr.xml
modules/http2/mod_http2.c
server/util_expr_eval.c

diff --git a/CHANGES b/CHANGES
index 036e3e0b362bb6270920e5e59ce4af0b2edf305b..f73f06c4b6689268508657823398e2b9bb8f2ede 100644 (file)
--- 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.
index 257eb1d9a4cf1f3ed171ff3822a1ecb91a65e445..e6931be8b2c349e59be5ec0861c3ded6aece5079 100644 (file)
@@ -270,6 +270,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>HANDLER</code></td>
         <td>The name of the <a href="handler.html">handler</a> creating
             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>
         <td>"<code>on</code>" if the request uses https,
             "<code>off</code>" otherwise</td></tr>
index 06b0b7799ac0c0581a5483916f149afd918539b3..809a883276513fd912ee50b342e1f9c79297f196 100644 (file)
@@ -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.
index 5a8f207eadce51f96747cea189b9209004e9c2f7..d8428ed98a30a3ebbd3a1cb260e293c99b628fdf 100644 (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 *));
 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;