For those following this thread, here is a update. You can build a module that is able to insert a trailer by adding a filter and ap_hook_create_request call.
You have to have a ap_hook_create_request call that runs after http_core.c and loops over the r->output_filters and removes ap_content_length_filter_handle. Then you have a AP_FTYPE_TRANSCODE+1 filter (chunk filter is AP_FTYPE_TRANSCODE and you want to be after) that loops over the brigade looking for a bucket that is: ASCII_ZERO ASCII_CRLF ASCII_CRLF followed by a APR_BUCKET_IS_EOS bucket. Remove it and replaces it with: ASCII_ZERO ASCII_CRLF <tailer string> ASCII_CRLF and you have chunked encoding with a trailer. Brian On Apr 22, 2010, at 10:39 PM, Brian J. France wrote: > On Apr 22, 2010, at 8:40 PM, Mark Nottingham wrote: >> I couldn't find any obvious way to set HTTP trailers in Apache 2.x without >> taking over all response processing (a la nph). >> >> Did I miss something? > > > I started hacking on this at work, but got the point where I can't insert a > filter in the right spot. > > The problem I ran into is that if the Content-Length header is set (which > ap_content_length_filter_handle sets), then the chunking filter doesn't kick > in. Something about wanting to use sendfile so don't chunk. > > I can't get a filter inserted after ap_content_length_filter_handle, but > before ap_http_header_filter (which adds the chunking filter). > > My plan was to insert a filter that removes the Content-Length header so the > response will be chunked and add another filter after the chunking filter > that would search for ASCII_ZERO ASCII_CRLF ASCII_CRLF and insert the trailer > data before the last ASCII_CRLF. This was just a proof of concept to see if > it would work and output data in the right format. > > If it all worked my plan was add a trailers hook and call the hook in > chunk_filter.c in place of the /* <trailers> */ comment. > > Brian > > After typing this up and working through it again, I think I can add a filter > AP_FTYPE_TRANSCODE+1 for the after chunking filter and AP_FTYPE_PROTOCOL+1 > and get them to be in the right order. Will test that out now. >
