]> granicus.if.org Git - apache/commitdiff
core: Split ap_create_request() from ap_read_request()
authorGraham Leggett <minfrin@apache.org>
Mon, 7 Mar 2016 23:55:08 +0000 (23:55 +0000)
committerGraham Leggett <minfrin@apache.org>
Mon, 7 Mar 2016 23:55:08 +0000 (23:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1734009 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/http_protocol.h
modules/http2/h2_request.c
server/protocol.c

diff --git a/CHANGES b/CHANGES
index ab351839f817be87f38a73b8e90da807d1094f61..dfab7323a935f2e776e979ac1dddaae677474531 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) core: Split ap_create_request() from ap_read_request(). [Graham Leggett]
+
   *) mod_ssl: Don't lose track of the SSL context if the ssl_run_pre_handshake()
      hook returns an error. [Graham Leggett]
 
index 9789081d6f5831152f3d62433ddd8ad812007f3a..c73c9f21c8ec1d84cf4cd0509aec792bd5b7f3bb 100644 (file)
  *                         the request_rec, with ap_get_useragent_host()
  * 20150222.12 (2.5.0-dev) Add complete_connection hook,
  *                         ap_filter_complete_connection().
+ * 20150222.13 (2.5.0-dev) Add ap_create_request().
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20150222
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 12                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 13                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index a9a06b05821d5e12ed5fc0b2a547cf150ace33ba..581540693f88bc77e4568d8838f08e89209cd883 100644 (file)
@@ -53,6 +53,13 @@ AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
  * or control the ones that eventually do.
  */
 
+/**
+ * Read an empty request and set reasonable defaults.
+ * @param c The current connection
+ * @return The new request_rec
+ */
+request_rec *ap_create_request(conn_rec *c);
+
 /**
  * Read a request and fill in the fields.
  * @param c The current connection
index 18509dfc12510765b1919ca3a302ca04b3716d1b..2c227505598ee79c2c94f3312cd98b6fc4419f41 100644 (file)
@@ -356,58 +356,12 @@ h2_request *h2_request_clone(apr_pool_t *p, const h2_request *src)
 
 request_rec *h2_request_create_rec(const h2_request *req, conn_rec *conn)
 {
-    request_rec *r;
-    apr_pool_t *p;
     int access_status = HTTP_OK;    
     
-    apr_pool_create(&p, conn->pool);
-    apr_pool_tag(p, "request");
-    r = apr_pcalloc(p, sizeof(request_rec));
-    AP_READ_REQUEST_ENTRY((intptr_t)r, (uintptr_t)conn);
-    r->pool            = p;
-    r->connection      = conn;
-    r->server          = conn->base_server;
-    
-    r->user            = NULL;
-    r->ap_auth_type    = NULL;
-    
-    r->allowed_methods = ap_make_method_list(p, 2);
-    
-    r->headers_in      = apr_table_clone(r->pool, req->headers);
-    r->trailers_in     = apr_table_make(r->pool, 5);
-    r->subprocess_env  = apr_table_make(r->pool, 25);
-    r->headers_out     = apr_table_make(r->pool, 12);
-    r->err_headers_out = apr_table_make(r->pool, 5);
-    r->trailers_out    = apr_table_make(r->pool, 5);
-    r->notes           = apr_table_make(r->pool, 5);
-    
-    r->request_config  = ap_create_request_config(r->pool);
-    /* Must be set before we run create request hook */
-    
-    r->proto_output_filters = conn->output_filters;
-    r->output_filters  = r->proto_output_filters;
-    r->proto_input_filters = conn->input_filters;
-    r->input_filters   = r->proto_input_filters;
-    ap_run_create_request(r);
-    r->per_dir_config  = r->server->lookup_defaults;
-    
-    r->sent_bodyct     = 0;                      /* bytect isn't for body */
-    
-    r->read_length     = 0;
-    r->read_body       = REQUEST_NO_BODY;
-    
-    r->status          = HTTP_OK;  /* Until further notice */
-    r->header_only     = 0;
-    r->the_request     = NULL;
-    
-    /* Begin by presuming any module can make its own path_info assumptions,
-     * until some module interjects and changes the value.
-     */
-    r->used_path_info = AP_REQ_DEFAULT_PATH_INFO;
-    
-    r->useragent_addr = conn->client_addr;
-    r->useragent_ip = conn->client_ip;
-    
+    request_rec *r = ap_create_request(c);
+
+    r->headers_in = apr_table_clone(r->pool, req->headers);
+
     ap_run_pre_read_request(r, conn);
     
     /* Time to populate r with the data we have. */
index 6bc597eb6e1886b87a54362c67926ea4653d2642..c6950a7d44db894b9513f33bcf8223c6a7e6672b 100644 (file)
@@ -1003,16 +1003,10 @@ AP_DECLARE(void) ap_get_mime_headers(request_rec *r)
     apr_brigade_destroy(tmp_bb);
 }
 
-request_rec *ap_read_request(conn_rec *conn)
+request_rec *ap_create_request(conn_rec *conn)
 {
     request_rec *r;
     apr_pool_t *p;
-    const char *expect;
-    int access_status;
-    apr_bucket_brigade *tmp_bb;
-    apr_socket_t *csd;
-    apr_interval_time_t cur_timeout;
-
 
     apr_pool_create(&p, conn->pool);
     apr_pool_tag(p, "request");
@@ -1051,6 +1045,7 @@ request_rec *ap_read_request(conn_rec *conn)
     r->read_body       = REQUEST_NO_BODY;
 
     r->status          = HTTP_OK;  /* Until further notice */
+    r->header_only     = 0;
     r->the_request     = NULL;
 
     /* Begin by presuming any module can make its own path_info assumptions,
@@ -1061,6 +1056,20 @@ request_rec *ap_read_request(conn_rec *conn)
     r->useragent_addr = conn->client_addr;
     r->useragent_ip = conn->client_ip;
 
+    return r;
+}
+
+request_rec *ap_read_request(conn_rec *conn)
+{
+    const char *expect;
+    int access_status;
+    apr_bucket_brigade *tmp_bb;
+    apr_socket_t *csd;
+    apr_interval_time_t cur_timeout;
+
+
+    request_rec *r = ap_create_request(conn);
+
     tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
 
     ap_run_pre_read_request(r, conn);