]> granicus.if.org Git - apache/commitdiff
Switch mod_proxy to using the brigade/filter calls directly rather than
authorJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 30 May 2002 07:33:59 +0000 (07:33 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 30 May 2002 07:33:59 +0000 (07:33 +0000)
the *_client_block calls.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95394 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/mod_proxy.c
modules/proxy/proxy_http.c

diff --git a/CHANGES b/CHANGES
index 59c6092ec3190e052f52dd80df45715ee6b9961d..83bab11435de517df902b6f2971caf79aefe13be 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,8 +9,8 @@ Changes with Apache 2.0.37
      Elimiates possible gpfault or garbage title without the -t option.
      [William Rowe]
 
-  *) Rewrite mod_cgi and mod_cgid's input handling to use brigades and input
-     filters.  [Justin Erenkrantz]
+  *) Rewrite mod_cgi, mod_cgid, and mod_proxy input handling to use
+     brigades and input filters.  [Justin Erenkrantz]
 
   *) Allow ap_http_filter (HTTP_IN) to return EOS when there is no request
      body.  [Justin Erenkrantz]
index 587a1114df68ed0b1b9f6ee699fef08082d1eb2e..513c82045c4508041699ac23d6ee436d7dad4e2d 100644 (file)
@@ -394,9 +394,6 @@ static int proxy_handler(request_rec *r)
     apr_table_set(r->headers_in, "Max-Forwards", 
                   apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0));
 
-    if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
-        return rc;
-
     url = r->filename + 6;
     p = strchr(url, ':');
     if (p == NULL)
index 589d44d6bc42a59c2955a1ea220ee4027fcf2094..ee9c75da1bb155ab2af8c0053a42573a774c973f 100644 (file)
@@ -419,12 +419,11 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
                                    char *url, apr_bucket_brigade *bb,
                                    char *server_portstr) {
     conn_rec *c = r->connection;
-    char buffer[HUGE_STRING_LEN];
     char *buf;
     apr_bucket *e;
     const apr_array_header_t *headers_in_array;
     const apr_table_entry_t *headers_in;
-    int counter;
+    int counter, seen_eos;
     apr_status_t status;
 
     /*
@@ -620,22 +619,42 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
     }
 
     /* send the request data, if any. */
-    if (ap_should_client_block(r)) {
-        while ((counter = ap_get_client_block(r, buffer, sizeof(buffer))) > 0) {
-            e = apr_bucket_pool_create(buffer, counter, p, c->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(bb, e);
-            e = apr_bucket_flush_create(c->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(bb, e);
-            status = ap_pass_brigade(origin->output_filters, bb);
-            if (status != APR_SUCCESS) {
-                ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
-                             "proxy: pass request data failed to %pI (%s)",
-                             p_conn->addr, p_conn->name);
-                return status;
+    seen_eos = 0;
+    do {
+        status = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
+                                APR_BLOCK_READ, HUGE_STRING_LEN);
+
+        if (status != APR_SUCCESS) {
+            return status;
+        }
+
+        /* If this brigade contain EOS, either stop or remove it. */
+        if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
+            /* As a shortcut, if this brigade is simply an EOS bucket,
+             * don't send anything down the filter chain.
+             */
+            if (APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(bb))) {
+                break;
             }
-            apr_brigade_cleanup(bb);
+
+            /* We can't pass this EOS to the output_filters. */
+            APR_BUCKET_REMOVE(APR_BRIGADE_LAST(bb));
+            seen_eos = 1;
         }
-    }
+
+        e = apr_bucket_flush_create(c->bucket_alloc);
+        APR_BRIGADE_INSERT_TAIL(bb, e);
+
+        status = ap_pass_brigade(origin->output_filters, bb);
+        if (status != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
+                         "proxy: pass request data failed to %pI (%s)",
+                         p_conn->addr, p_conn->name);
+            return status;
+        }
+        apr_brigade_cleanup(bb);
+    } while (!seen_eos);
+
     return APR_SUCCESS;
 }