httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Strauss ...@netspace.org>
Subject [PATCH] add ap_send_http_header back to Apache2
Date Wed, 04 Aug 2004 21:01:02 GMT
These's been a recent discussion over on the modperl list
(reference: http://marc.theaimsgroup.com/?t=109122984600001&r=1&w=2)
with regards to C-L and HEAD requests.  Dynamic handlers that know the
length of the content, but do not want to generate the content must send
something (anything) down the filter chain before returned (before EOS),
otherwise the content-length filter strips ends up stripping the C-L header.

Since the body is discarded for HEAD requests, sending anything works
(because then the content-length filter steps out of the way).
The cleanest solution seems to be to send a flush bucket to trigger
the sending of headers.


Since this seems to me to be something that lots of dynamic handlers might
use, I'd like to ask that ap_send_http_header() be re-added to Apache2.
It's implementation currently is simply to send a flush bucket down the
filter chain.

Even though HTTP headers are sent when needed, there are occasions when
dynamic handlers want to say "send headers now".  ap_send_http_header()
should provide that for them.  This is instead of relying on the current
behavior of a flush bucket, or can this behavior be relied upon and can
it be documented as such?  Thanks!

Cheers,
Glenn


diff -ruN httpd-2.0.50/include/ap_compat.h httpd-2.0.50-new/include/ap_compat.h
--- httpd-2.0.50/include/ap_compat.h	2004-02-09 15:54:33.000000000 -0500
+++ httpd-2.0.50-new/include/ap_compat.h	2004-08-04 15:22:08.657596200 -0400
@@ -22,6 +22,5 @@
 /* redefine 1.3.x symbols to the new symbol names */
 
 #define MODULE_VAR_EXPORT    AP_MODULE_DECLARE_DATA
-#define ap_send_http_header(r) ;
 
 #endif /* AP_COMPAT_H */
diff -ruN httpd-2.0.50/include/http_protocol.h httpd-2.0.50-new/include/http_protocol.h
--- httpd-2.0.50/include/http_protocol.h	2004-06-11 16:46:41.000000000 -0400
+++ httpd-2.0.50-new/include/http_protocol.h	2004-08-04 15:26:59.078445520 -0400
@@ -73,6 +73,12 @@
 /* Finish up stuff after a request */
 
 /**
+ * Triggers sending of response headers, if not already sent to client
+ * @param r The current request
+ */
+AP_DECLARE(apr_status_t) ap_send_http_header(request_rec *r);
+
+/**
  * Called at completion of sending the response.  It sends the terminating
  * protocol information.
  * @param r The current request
diff -ruN httpd-2.0.50/modules/http/http_protocol.c httpd-2.0.50-new/modules/http/http_protocol.c
--- httpd-2.0.50/modules/http/http_protocol.c	2004-02-09 15:53:18.000000000 -0500
+++ httpd-2.0.50-new/modules/http/http_protocol.c	2004-08-04 15:44:59.746159056 -0400
@@ -1275,6 +1275,15 @@
     basic_http_header(r, bb, protocol);
 }
 
+AP_DECLARE(apr_status_t) ap_send_http_header(request_rec * const r)
+{
+    /* (similar to ap_rflush() but returns (apr_status_t) instead of (int)) */
+    apr_bucket_alloc_t * const bucket_alloc = r->connection->bucket_alloc;
+    apr_bucket_brigade * const bb = apr_brigade_create(r->pool, bucket_alloc);
+    APR_BRIGADE_INSERT_HEAD(bb, apr_bucket_flush_create(bucket_alloc));
+    return ap_pass_brigade(r->output_filters, bb);
+}
+
 /* Navigator versions 2.x, 3.x and 4.0 betas up to and including 4.0b2
  * have a header parsing bug.  If the terminating \r\n occur starting
  * at offset 256, 257 or 258 of output then it will not properly parse

Mime
View raw message