httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1735176 - in /httpd/httpd/trunk: CHANGES modules/http/http_core.c
Date Tue, 15 Mar 2016 23:13:43 GMT
Author: minfrin
Date: Tue Mar 15 23:13:43 2016
New Revision: 1735176

URL: http://svn.apache.org/viewvc?rev=1735176&view=rev
Log:
mod_http: Make sure HTTP filters are added on HTTP requests only.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/http/http_core.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1735176&r1=1735175&r2=1735176&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Mar 15 23:13:43 2016
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_http: Make sure HTTP filters are added on HTTP requests only.
+     [Graham Leggett]
+
   *) mpm: Generalise the ap_mpm_register_socket functions to accept pipes
      or sockets. [Graham Leggett]
 

Modified: httpd/httpd/trunk/modules/http/http_core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_core.c?rev=1735176&r1=1735175&r2=1735176&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_core.c (original)
+++ httpd/httpd/trunk/modules/http/http_core.c Tue Mar 15 23:13:43 2016
@@ -34,6 +34,8 @@
 
 #include "mod_core.h"
 
+module AP_MODULE_DECLARE_DATA http_module;
+
 /* Handles for core filters */
 AP_DECLARE_DATA ap_filter_rec_t *ap_http_input_filter_handle;
 AP_DECLARE_DATA ap_filter_rec_t *ap_http_header_filter_handle;
@@ -48,6 +50,10 @@ AP_DECLARE_DATA const char *ap_multipart
  */
 static int async_mpm = 0;
 
+typedef struct {
+    int is_http;
+} http_conn_conf;
+
 static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy,
                                           const char *arg)
 {
@@ -242,9 +248,29 @@ static int ap_process_http_sync_connecti
     return OK;
 }
 
+static int http_pre_connection(conn_rec *c, void *csd)
+{
+    const char *protocol = ap_get_protocol(c);
+
+    http_conn_conf *cconf = apr_pcalloc(c->pool, sizeof(*cconf));
+
+    if (!strcmp(AP_PROTOCOL_HTTP1, protocol)) {
+        cconf->is_http = 1;
+    }
+
+    ap_set_module_config(c->conn_config, &http_module, cconf);
+
+    return OK;
+}
+
 static int ap_process_http_connection(conn_rec *c)
 {
-    if (async_mpm && !c->clogging_input_filters) {
+    http_conn_conf *cconf = ap_get_module_config(c->conn_config, &http_module);
+
+    if (!cconf || !cconf->is_http) {
+        return DECLINED;
+    }
+    else if (async_mpm && !c->clogging_input_filters) {
         return ap_process_http_async_connection(c);
     }
     else {
@@ -254,7 +280,6 @@ static int ap_process_http_connection(co
 
 static int http_create_request(request_rec *r)
 {
-    /* FIXME: we must only add these filters if we are an HTTP request */
     if (!r->main && !r->prev) {
         ap_add_output_filter_handle(ap_byterange_filter_handle,
                                     NULL, r, r->connection);
@@ -295,6 +320,8 @@ static int http_post_config(apr_pool_t *
 static void register_hooks(apr_pool_t *p)
 {
     ap_hook_post_config(http_post_config, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_pre_connection(http_pre_connection, NULL, NULL,
+            APR_HOOK_REALLY_LAST);
     ap_hook_process_connection(ap_process_http_connection, NULL, NULL,
                                APR_HOOK_REALLY_LAST);
     ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);



Mime
View raw message