]> granicus.if.org Git - apache/commitdiff
announcing Alt-Svc only on first request per connection, using handler independent...
authorStefan Eissing <icing@apache.org>
Mon, 17 Aug 2015 14:02:07 +0000 (14:02 +0000)
committerStefan Eissing <icing@apache.org>
Mon, 17 Aug 2015 14:02:07 +0000 (14:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1696279 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_alt_svc.c

index 2eaab12791fbe5c3990730627729efb5c648fff1..9db208149e90359eb148ec492cf6a5199f6cf225 100644 (file)
@@ -16,6 +16,8 @@
 #include <apr_strings.h>
 #include <httpd.h>
 #include <http_core.h>
+#include <http_connection.h>
+#include <http_protocol.h>
 #include <http_log.h>
 
 #include "h2_private.h"
 #include "h2_h2.h"
 #include "h2_util.h"
 
-static int h2_alt_svc_request_handler(request_rec *r);
+static int h2_alt_svc_handler(request_rec *r);
 
 void h2_alt_svc_register_hooks(void)
 {
-    ap_hook_handler(h2_alt_svc_request_handler, NULL, NULL, APR_HOOK_LAST);
+    ap_hook_post_read_request(h2_alt_svc_handler, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 /**
@@ -69,12 +71,18 @@ h2_alt_svc *h2_alt_svc_parse(const char *s, apr_pool_t *pool) {
 
 #define h2_alt_svc_IDX(list, i) ((h2_alt_svc**)(list)->elts)[i]
 
-static int h2_alt_svc_request_handler(request_rec *r)
+static int h2_alt_svc_handler(request_rec *r)
 {
-    h2_ctx *ctx = h2_ctx_rget(r);
+    h2_ctx *ctx;
     h2_config *cfg;
     int i;
     
+    if (r->connection->keepalives > 0) {
+        /* Only announce Alt-Svc on the first response */
+        return DECLINED;
+    }
+    
+    ctx = h2_ctx_rget(r);
     if (h2_ctx_is_active(ctx) || h2_ctx_is_task(ctx)) {
         return DECLINED;
     }
@@ -82,7 +90,7 @@ static int h2_alt_svc_request_handler(request_rec *r)
     cfg = h2_config_rget(r);
     if (r->hostname && cfg && cfg->alt_svcs && cfg->alt_svcs->nelts > 0) {
         const char *alt_svc_used = apr_table_get(r->headers_in, "Alt-Svc-Used");
-        if (!alt_svc_used /*|| (alt_svc_used[0] == '0')*/) {
+        if (!alt_svc_used) {
             /* We have alt-svcs defined and client is not already using
              * one, announce the services that were configured and match. 
              * The security of this connection determines if we allow