You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Joe Schaefer <jo...@yahoo.com> on 2013/02/10 17:05:34 UTC

chunked trailers input filter processing by ap_http_filter should be documented

So ap_http_filter winds up calling ap_get_mime_headers
once it recognizes that the request body has finished,
to process the trailing headers on chunked requests.
This is actually a strange thing to do, because it means
ap_http_filter winds up calling ap_get_brigade on
r->input_filters with AP_MODE_GETLINE set, right in the middle of an
existing ap_get_brigade sequence on the filter chain.
In other words, this recursion only works if all
post-protocol filters are written to punt on processing
AP_MODE_GETLINE invocations- this is what we need to
document somewhere if we don't want to fix the code.

It would be logically better if there were a way to pass a
ap_filter_t argument to ap_get_mime_headers so ap_http_filter
didn't need to reach backwards in the input filter chain just
to finish its HTTP protocol handling.

Re: chunked trailers input filter processing by ap_http_filter should be documented

Posted by Joe Schaefer <jo...@yahoo.com>.
Thx Bill!  I will let a few days of lazy consensus
pass before committing this to trunk.





>________________________________
> From: William A. Rowe Jr. <wr...@rowe-clan.net>
>To: dev@httpd.apache.org 
>Cc: joe_schaefer@yahoo.com 
>Sent: Tuesday, February 12, 2013 11:52 AM
>Subject: Re: chunked trailers input filter processing by ap_http_filter should be documented
> 
>On Sun, 10 Feb 2013 08:25:35 -0800 (PST)
>Joe Schaefer <jo...@yahoo.com> wrote:
>
>> Here's a sledgehammer patch to ap_rgetline_core()
>> to replace r->input_filters with r->proto_input_filters.
>> This would still mean protocol filters behind ap_http_filter
>> would need to punt on these calls, but that's a lot
>> more reasonable than imposing it on AP_FTYPE_RESOURCE
>> and similar filters as well.
>
>+1, seems much saner.  Request filters have no business reading
>beyond end of request body.
>
>
>

Re: chunked trailers input filter processing by ap_http_filter should be documented

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On Sun, 10 Feb 2013 08:25:35 -0800 (PST)
Joe Schaefer <jo...@yahoo.com> wrote:

> Here's a sledgehammer patch to ap_rgetline_core()
> to replace r->input_filters with r->proto_input_filters.
> This would still mean protocol filters behind ap_http_filter
> would need to punt on these calls, but that's a lot
> more reasonable than imposing it on AP_FTYPE_RESOURCE
> and similar filters as well.

+1, seems much saner.  Request filters have no business reading
beyond end of request body.

Re: chunked trailers input filter processing by ap_http_filter should be documented

Posted by Joe Schaefer <jo...@yahoo.com>.
Here's a sledgehammer patch to ap_rgetline_core()
to replace r->input_filters with r->proto_input_filters.
This would still mean protocol filters behind ap_http_filter
would need to punt on these calls, but that's a lot
more reasonable than imposing it on AP_FTYPE_RESOURCE
and similar filters as well.



Index: protocol.c
===================================================================
--- protocol.c    (revision 1331861)
+++ protocol.c    (working copy)
@@ -229,7 +229,7 @@
 
     for (;;) {
         apr_brigade_cleanup(bb);
-        rv = ap_get_brigade(r->input_filters, bb, AP_MODE_GETLINE,
+        rv = ap_get_brigade(r->proto_input_filters, bb, AP_MODE_GETLINE,
                             APR_BLOCK_READ, 0);
         if (rv != APR_SUCCESS) {
             return rv;
@@ -346,7 +346,7 @@
             apr_brigade_cleanup(bb);
 
             /* We only care about the first byte. */
-            rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE,
+            rv = ap_get_brigade(r->proto_input_filters, bb, AP_MODE_SPECULATIVE,
                                 APR_BLOCK_READ, 1);
             if (rv != APR_SUCCESS) {
                 return rv;







>________________________________
> From: Joe Schaefer <jo...@yahoo.com>
>To: "dev@httpd.apache.org" <de...@httpd.apache.org> 
>Sent: Sunday, February 10, 2013 11:05 AM
>Subject: chunked trailers input filter processing by ap_http_filter should be documented
> 
>
>So ap_http_filter winds up calling ap_get_mime_headers
>once it recognizes that the request body has finished,
>to process the trailing headers on chunked requests.
>This is actually a strange thing to do, because it means
>ap_http_filter winds up calling ap_get_brigade on
>r->input_filters with AP_MODE_GETLINE set, right in the middle of an
>existing ap_get_brigade sequence on the filter chain.
>In other words, this recursion only works if all
>post-protocol filters are written to punt on processing
>AP_MODE_GETLINE invocations- this is what we need to
>document somewhere if we don't want to fix the code.
>
>
>It would be logically better if there were a way to pass a
>ap_filter_t argument to ap_get_mime_headers so ap_http_filter
>didn't need to reach backwards in the input filter chain just
>to finish its HTTP protocol handling.
>
>
>
>
>
>