On Mon, Oct 28, 2013 at 2:23 AM, Eric Covener <cove...@gmail.com> wrote:
> On Tue, Oct 22, 2013 at 2:18 PM, Yann Ylavic <ylavic....@gmail.com> wrote: > > -AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, > > apr_bucket_brigade *bb) > > +struct ap_mime_headers_ctx_t { > > + int fields_read; > > + char *last_field; > > + apr_size_t last_len; > > + apr_size_t alloc_len; > > + unsigned int fold :1, > > + done :1; > > +}; > > + > > +AP_DECLARE(apr_status_t) > > +ap_get_mime_headers_ex(request_rec *r, apr_bucket_brigade *bb, > apr_table_t > > *to, > > + ap_filter_t *from, apr_read_type_e block, > > + ap_mime_headers_ctx_t **pctx) > > { > > - char *last_field = NULL; > > - apr_size_t last_len = 0; > > - apr_size_t alloc_len = 0; > > > Making my way through the review, had a tough time following the need > for this part. Any pointers? > I first simply created ap_get_mime_headers_ex() with the new destination table argument "to" so that ap_http_filter() would use with r->trailers_in instead of r->headers_in. Then I realized that as well as adding yet another ap_get_mime_headers*() function, this one had to be prepared to handle non-blocking mode, like ap_http_filter() is ... but with the trailers (which are currently read in blocking mode whatever ap_http_filter() calling mode is). So I added ap_mime_headers_ctx_t to make ap_get_mime_headers_ex() reentrant (with a given context, which ap_http_filter() can associate with its own context). ap_http_filter() is now able to handle non-blocking trailers in its state machine (eg. in the corresponding BODY_CHUNK_TRAILER state), but since ap_get_mime_headers() would ap_get_brigade(r->proto_input_filters), that would end up with an infinite recursion between ap_http_filter() and ap_get_mime_headers(). Hence the ap_get_mime_headers_ex()'s argument "from", which aims to receive ap_http_filter()->next...