]> granicus.if.org Git - apache/commitdiff
Hack headers to work semi-properly. This is a hack that will need to be
authorRyan Bloom <rbb@apache.org>
Sat, 21 Oct 2000 14:20:14 +0000 (14:20 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 21 Oct 2000 14:20:14 +0000 (14:20 +0000)
fixed, but it is good enough for now.  The idea is that headers shouldn't
flow through the BUFF anymore.  Now, we have a header filter that is
called at the end of the request-filter chain.  This filter writes the
headers directly to the connection filters.

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

include/http_protocol.h
modules/http/http_core.c
modules/http/http_protocol.c

index eff978a9f5f379b5f52d2fbe6efac5ce147f46ec..efbf29f71a26836cb8d6b6be0e04270ce8fbd2bb 100644 (file)
@@ -112,6 +112,8 @@ AP_DECLARE(void) ap_basic_http_header(request_rec *r);
  */
 AP_DECLARE(void) ap_send_http_header(request_rec *l);
 
+AP_CORE_DECLARE(int) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b);
+
 /* Send the response to special method requests */
 
 AP_DECLARE(int) ap_send_http_trace(request_rec *r);
index bd914f749c1fe0970a7f38f3096c172a68a195c7..77f1c9bf0b593b2e2cc7bf70954d482a31569c6a 100644 (file)
@@ -3579,6 +3579,7 @@ static void register_hooks(void)
     ap_register_input_filter("HTTP_IN", http_filter, AP_FTYPE_CONNECTION);
     ap_register_input_filter("DECHUNK", dechunk_filter, AP_FTYPE_CONNECTION + 1);
     ap_register_input_filter("CORE_IN", core_input_filter, AP_FTYPE_CONNECTION);
+    ap_register_output_filter("HTTP_HEADER", ap_http_header_filter, AP_FTYPE_CONTENT + 1);
     ap_register_output_filter("CORE", core_output_filter, AP_FTYPE_CONNECTION + 1);
     ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter, 
                               AP_FTYPE_CONTENT);
index 5e8e2ff2a2dca23d46e0280e798189b8b593e9ad..8d3ca3ffc8ffc2ce2b9fe698b3c467626e2a304c 100644 (file)
@@ -1413,6 +1413,8 @@ request_rec *ap_read_request(conn_rec *conn)
                ? &r->server->keep_alive_timeout
                : &r->server->timeout);
 
+    ap_add_output_filter("HTTP_HEADER", NULL, r, r->connection);
+
     /* Get the request... */
     if (!read_request_line(r)) {
         if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
@@ -1768,7 +1770,17 @@ AP_DECLARE(const char *) ap_get_status_line(int status)
 AP_DECLARE_NONSTD(int) ap_send_header_field(request_rec *r,
     const char *fieldname, const char *fieldval)
 {
-    return (0 < checked_bputstrs(r, fieldname, ": ", fieldval, CRLF, NULL));
+    char *headfield;
+    ap_bucket *headbuck;
+    ap_bucket_brigade *bb;
+
+    headfield = apr_pstrcat(r->pool, fieldname, ": ", fieldval, CRLF, NULL);
+    headbuck = ap_bucket_create_pool(headfield, strlen(headfield), r->pool);
+    bb = ap_brigade_create(r->pool);
+    AP_BRIGADE_INSERT_HEAD(bb, headbuck);
+
+    ap_pass_brigade(r->connection->output_filters, bb);
+    return 1;
 }
 
 AP_DECLARE(void) ap_basic_http_header(request_rec *r)
@@ -1828,13 +1840,24 @@ AP_DECLARE(void) ap_basic_http_header(request_rec *r)
  */
 static void terminate_header(request_rec *r)
 {
-    long int bs;
+    char *headfield;
+    ap_bucket *headbuck;
+    ap_bucket_brigade *bb;
+
+    headfield = apr_pstrcat(r->pool, CRLF, NULL);
+    headbuck = ap_bucket_create_pool(headfield, strlen(headfield), r->pool);
+    bb = ap_brigade_create(r->pool);
+    AP_BRIGADE_INSERT_HEAD(bb, headbuck);
+
+    ap_pass_brigade(r->connection->output_filters, bb);
 
+#if 0
     ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
     if (bs >= 255 && bs <= 257)
         (void) checked_bputs("X-Pad: avoid browser bug" CRLF, r);
 
     (void) checked_bputs(CRLF, r);  /* Send the terminating empty line */
+#endif
 }
 
 /*
@@ -2195,16 +2218,29 @@ static void fixup_vary(request_rec *r)
 }
 
 AP_DECLARE(void) ap_send_http_header(request_rec *r)
+{
+}
+
+AP_CORE_DECLARE(int) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b)
 {
     int i;
     const long int zero = 0L;
     char *date = NULL;
+    request_rec *r = f->r;
+/* This hack should be removed as soon as we can remove filters */
+    static int foobar = 0;
+
+    if (foobar != 0) {
+        return ap_pass_brigade(f->next, b);
+    }
+    foobar++;
+/* END HACK */
 
     if (r->assbackwards) {
         if (!r->main)
             ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
         r->sent_bodyct = 1;
-        return;
+        return APR_SUCCESS;
     }
 
     /*
@@ -2280,7 +2316,6 @@ AP_DECLARE(void) ap_send_http_header(request_rec *r)
         apr_rfc822_date(date, r->request_time);
         apr_table_addn(r->headers_out, "Expires", date);
     }
-
     apr_table_do((int (*) (void *, const char *, const char *)) ap_send_header_field,
                 (void *) r, r->headers_out, NULL);
 
@@ -2293,6 +2328,7 @@ AP_DECLARE(void) ap_send_http_header(request_rec *r)
     if (r->chunked) {
         ap_bsetflag(r->connection->client, B_CHUNK, 1);
     }
+    return ap_pass_brigade(f->next, b);
 }
 
 /* finalize_request_protocol is called at completion of sending the