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

2013-02-12 Thread William A. Rowe Jr.
On Sun, 10 Feb 2013 08:25:35 -0800 (PST)
Joe Schaefer joe_schae...@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

2013-02-12 Thread Joe Schaefer
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_schae...@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 joe_schae...@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.




chunked trailers input filter processing by ap_http_filter should be documented

2013-02-10 Thread Joe Schaefer
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

2013-02-10 Thread Joe Schaefer
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 joe_schae...@yahoo.com
To: dev@httpd.apache.org dev@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.