427781
diff --git a/modules/http/http_request.c b/modules/http/http_request.c
427781
index c97dc77..9885de4 100644
427781
--- a/modules/http/http_request.c
427781
+++ b/modules/http/http_request.c
427781
@@ -227,11 +227,21 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
427781
     ap_die_r(type, r, r->status);
427781
 }
427781
 
427781
-static void check_pipeline(conn_rec *c)
427781
+#define RETRIEVE_BRIGADE_FROM_POOL(bb, key, pool, allocator) do {       \
427781
+    apr_pool_userdata_get((void **)&bb, key, pool);                     \
427781
+    if (bb == NULL) {                                                   \
427781
+        bb = apr_brigade_create(pool, allocator);                       \
427781
+        apr_pool_userdata_setn((const void *)bb, key, NULL, pool);      \
427781
+    }                                                                   \
427781
+    else {                                                              \
427781
+        apr_brigade_cleanup(bb);                                        \
427781
+    }                                                                   \
427781
+} while(0)
427781
+
427781
+static void check_pipeline(conn_rec *c, apr_bucket_brigade *bb)
427781
 {
427781
     if (c->keepalive != AP_CONN_CLOSE) {
427781
         apr_status_t rv;
427781
-        apr_bucket_brigade *bb = apr_brigade_create(c->pool, c->bucket_alloc);
427781
 
427781
         rv = ap_get_brigade(c->input_filters, bb, AP_MODE_SPECULATIVE,
427781
                             APR_NONBLOCK_READ, 1);
427781
@@ -245,11 +255,10 @@ static void check_pipeline(conn_rec *c)
427781
         else {
427781
             c->data_in_input_filters = 1;
427781
         }
427781
-        apr_brigade_destroy(bb);
427781
+        apr_brigade_cleanup(bb);
427781
     }
427781
 }
427781
 
427781
-
427781
 AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
427781
 {
427781
     apr_bucket_brigade *bb;
427781
@@ -260,11 +269,13 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
427781
      * this bucket is destroyed, the request will be logged and
427781
      * its pool will be freed
427781
      */
427781
-    bb = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
427781
+    RETRIEVE_BRIGADE_FROM_POOL(bb, "ap_process_request_after_handler_brigade",
427781
+                               c->pool, c->bucket_alloc);
427781
     b = ap_bucket_eor_create(r->connection->bucket_alloc, r);
427781
     APR_BRIGADE_INSERT_HEAD(bb, b);
427781
 
427781
     ap_pass_brigade(r->connection->output_filters, bb);
427781
+    apr_brigade_cleanup(bb);
427781
 
427781
     /* From here onward, it is no longer safe to reference r
427781
      * or r->pool, because r->pool may have been destroyed
427781
@@ -273,7 +284,7 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
427781
 
427781
     if (c->cs)
427781
         c->cs->state = CONN_STATE_WRITE_COMPLETION;
427781
-    check_pipeline(c);
427781
+    check_pipeline(c, bb);
427781
     AP_PROCESS_REQUEST_RETURN((uintptr_t)r, r->uri, r->status);
427781
     if (ap_extended_status) {
427781
         ap_time_process_request(c->sbh, STOP_PREQUEST);
427781
@@ -363,7 +374,8 @@ void ap_process_request(request_rec *r)
427781
     ap_process_async_request(r);
427781
 
427781
     if (!c->data_in_input_filters) {
427781
-        bb = apr_brigade_create(c->pool, c->bucket_alloc);
427781
+        RETRIEVE_BRIGADE_FROM_POOL(bb, "ap_process_request_after_handler_brigade",
427781
+                                   c->pool, c->bucket_alloc);
427781
         b = apr_bucket_flush_create(c->bucket_alloc);
427781
         APR_BRIGADE_INSERT_HEAD(bb, b);
427781
         rv = ap_pass_brigade(c->output_filters, bb);
427781
@@ -380,6 +392,7 @@ void ap_process_request(request_rec *r)
427781
                           "Timeout while writing data for URI %s to the"
427781
                           " client", r->unparsed_uri);
427781
         }
427781
+        apr_brigade_cleanup(bb);
427781
     }
427781
     if (ap_extended_status) {
427781
         ap_time_process_request(c->sbh, STOP_PREQUEST);