chance to compute the proper content-length before we try to send a set
of headers. If a handler wants to ignore the HEAD method, then it can
either just return from the handler function or pass an EOS bucket down
the filter stack. Either method will still get the headers sent to the
client.
This change allows handlers to actually run the request like it is a GET
request. The core itself will then ensure that no body is sent. This
allows us to get more information about the request before sending out the
headers for the HEAD request.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86954
13f79535-47bb-0310-9956-
ffa450edef68
return num_ranges;
}
+typedef struct header_filter_cts {
+ int headers_sent;
+} header_filter_ctx;
AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b)
{
int i;
ap_bucket_brigade *b2;
apr_size_t len = 0;
header_struct h;
+ header_filter_ctx *ctx = f->ctx;
AP_DEBUG_ASSERT(!r->main);
+ if (!ctx) {
+ ctx = apr_pcalloc(r->pool, sizeof(*ctx));
+ }
+
+ if (ctx->headers_sent) {
+ ap_brigade_destroy(b);
+ return AP_REQUEST_DONE;
+ }
+
if (r->assbackwards) {
r->bytes_sent = 0;
r->sent_bodyct = 1;
AP_BRIGADE_INSERT_HEAD(b2, e);
ap_pass_brigade(f->next, b2);
+ if (r->header_only) {
+ ap_brigade_destroy(b);
+ return AP_REQUEST_DONE;
+ }
+
if (r->chunked) {
/* The coalesce filter is useful to coalesce content from the ap_r*
* routines. Removing this filter should not break the server.