]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge of r1771001,1771015 from trunk:
authorStefan Eissing <icing@apache.org>
Wed, 23 Nov 2016 18:20:10 +0000 (18:20 +0000)
committerStefan Eissing <icing@apache.org>
Wed, 23 Nov 2016 18:20:10 +0000 (18:20 +0000)
mod_http2: new directive H2EarlyHints

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1771018 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_http2.xml
modules/http2/h2_config.c
modules/http2/h2_config.h
modules/http2/h2_session.c
modules/http2/h2_version.h

diff --git a/CHANGES b/CHANGES
index 2861e58575943ecf5cac4f344c27af4f0b3d646d..0f4e175b81ad306fb1df5e71fedb4d0456345db5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.4.24
 
+  *) mod_http2: new directive 'H2EarlyHints' to enable sending of HTTP status
+     103 interim responses. Disabled by default. [Stefan Eissing]
+     
   *) mod_ssl: Fix quick renegotiation (OptRenegotiaton) with no intermediate
      in the client certificate chain.  PR 55786.  [Yann Ylavic]
 
index 02134bbe9f7a6911693eaf86bb406312482de770..b7dcc959be883c8aa856742d041137f3a3fb642b 100644 (file)
@@ -972,4 +972,31 @@ H2TLSCoolDownSecs 0
         </usage>
     </directivesynopsis>
     
+    <directivesynopsis>
+        <name>H2EarlyHints</name>
+        <description>Determine sending of 103 status codes</description>
+        <syntax>H2EarlyHints on|off</syntax>
+        <default>H2EarlyHints off</default>
+        <contextlist>
+            <context>server config</context>
+            <context>virtual host</context>
+        </contextlist>
+        <compatibility>Available in version 2.4.24 and later.</compatibility>
+        
+        <usage>
+            <p>
+                This setting controls if HTTP status 103 interim responses are
+                forwarded to the client or not. By default, this is currently 
+                not the case since a range of clients still have trouble with
+                unexpected interim responses.
+            </p>
+            <p>
+                When set to <code>on</code>, PUSH resources announced with
+                <code>H2PushResource</code> will trigger an interim 103 response
+                before the final response. The 103 response will carry <code>Link</code>
+                headers that advise the <code>preload</code> of such resources. 
+            </p>
+        </usage>
+    </directivesynopsis>
+    
 </modulesynopsis>
index dec859705abe3c919e42c1baaa14ecf7b6f56af0..669d20e75ce0d827d4ea8e25a90df27509556943 100644 (file)
@@ -62,7 +62,8 @@ static h2_config defconf = {
     NULL,                   /* map of content-type to priorities */
     256,                    /* push diary size */
     0,                      /* copy files across threads */
-    NULL                    /* push list */
+    NULL,                   /* push list */
+    0,                      /* early hints, http status 103 */
 };
 
 void h2_config_init(apr_pool_t *pool)
@@ -97,6 +98,7 @@ static void *h2_config_create(apr_pool_t *pool,
     conf->push_diary_size      = DEF_VAL;
     conf->copy_files           = DEF_VAL;
     conf->push_list            = NULL;
+    conf->early_hints          = DEF_VAL;
     return conf;
 }
 
@@ -148,6 +150,7 @@ static void *h2_config_merge(apr_pool_t *pool, void *basev, void *addv)
     else {
         n->push_list        = add->push_list? add->push_list : base->push_list;
     }
+    n->early_hints          = H2_CONFIG_GET(add, base, early_hints);
     return n;
 }
 
@@ -203,6 +206,8 @@ apr_int64_t h2_config_geti64(const h2_config *conf, h2_config_var_t var)
             return H2_CONFIG_GET(conf, &defconf, push_diary_size);
         case H2_CONF_COPY_FILES:
             return H2_CONFIG_GET(conf, &defconf, copy_files);
+        case H2_CONF_EARLY_HINTS:
+            return H2_CONFIG_GET(conf, &defconf, early_hints);
         default:
             return DEF_VAL;
     }
@@ -588,6 +593,23 @@ static const char *h2_conf_add_push_res(cmd_parms *cmd, void *dirconf,
     return NULL;
 }
 
+static const char *h2_conf_set_early_hints(cmd_parms *parms,
+                                           void *arg, const char *value)
+{
+    h2_config *cfg = (h2_config *)h2_config_sget(parms->server);
+    if (!strcasecmp(value, "On")) {
+        cfg->early_hints = 1;
+        return NULL;
+    }
+    else if (!strcasecmp(value, "Off")) {
+        cfg->early_hints = 0;
+        return NULL;
+    }
+    
+    (void)arg;
+    return "value must be On or Off";
+}
+
 #define AP_END_CMD     AP_INIT_TAKE1(NULL, NULL, NULL, RSRC_CONF, NULL)
 
 const command_rec h2_cmds[] = {
@@ -631,6 +653,8 @@ const command_rec h2_cmds[] = {
                   OR_FILEINFO, "on to perform copy of file data"),
     AP_INIT_TAKE123("H2PushResource", h2_conf_add_push_res, NULL,
                    OR_FILEINFO, "add a resource to be pushed in this location/on this server."),
+    AP_INIT_TAKE1("H2EarlyHints", h2_conf_set_early_hints, NULL,
+                  RSRC_CONF, "on to enable interim status 103 responses"),
     AP_END_CMD
 };
 
index 08bde3b74012c14ea997d781a18e8a90d50b5e0b..1f2fe309d0a25c7df662b1a6a56f2c276707b723 100644 (file)
@@ -41,6 +41,7 @@ typedef enum {
     H2_CONF_PUSH,
     H2_CONF_PUSH_DIARY_SIZE,
     H2_CONF_COPY_FILES,
+    H2_CONF_EARLY_HINTS,
 } h2_config_var_t;
 
 struct apr_hash_t;
@@ -77,6 +78,7 @@ typedef struct h2_config {
     int push_diary_size;          /* # of entries in push diary */
     int copy_files;               /* if files shall be copied vs setaside on output */
     apr_array_header_t *push_list;/* list of h2_push_res configurations */
+    int early_hints;              /* support status code 103 */
 } h2_config;
 
 
index 7225201bfcea4412e4de5f3a664e8746a52c2edb..0a29a3b18cca9eaa7c6aff767fba5974e8bc0d72 100644 (file)
@@ -1501,6 +1501,14 @@ static apr_status_t on_stream_headers(h2_session *session, h2_stream *stream,
                            apr_itoa(stream->pool, connFlowOut));
         }
         
+        if (headers->status == 103 
+            && !h2_config_geti(session->config, H2_CONF_EARLY_HINTS)) {
+            /* suppress sending this to the client, it might have triggered 
+             * pushes and served its purpose nevertheless */
+            rv = 0;
+            goto leave;
+        }
+        
         ngh = h2_util_ngheader_make_res(stream->pool, headers->status, hout);
         rv = nghttp2_submit_response(session->ngh2, stream->id,
                                      ngh->nv, ngh->nvlen, pprovider);
index 27a298b3b9d084d1a453e5990101060994213774..f272c3c71fe499eb37c0a81b27119d6a10865306 100644 (file)
@@ -26,7 +26,7 @@
  * @macro
  * Version number of the http2 module as c string
  */
-#define MOD_HTTP2_VERSION "1.8.1"
+#define MOD_HTTP2_VERSION "1.8.2"
 
 /**
  * @macro
@@ -34,7 +34,7 @@
  * release. This is a 24 bit number with 8 bits for major number, 8 bits
  * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
  */
-#define MOD_HTTP2_VERSION_NUM 0x010801
+#define MOD_HTTP2_VERSION_NUM 0x010802
 
 
 #endif /* mod_h2_h2_version_h */