[CherryPy] #1097: Patch to support trailer headers for streamed responses

6 views
Skip to first unread message

CherryPy

unread,
Oct 3, 2011, 8:35:03 AM10/3/11
to cherrypy...@googlegroups.com
#1097: Patch to support trailer headers for streamed responses
---------------------------+------------------------------------------------
Reporter: l...@cern.ch | Owner: fumanchu
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords:
---------------------------+------------------------------------------------
I am attaching a patch to CP 3.1.2 which adds support for trailer headers
for streamed (chunked) responses. If streaming, response headers are reset
when body generation begins. Any `response.headers` set after that will be
output at the end as trailer headers. The application is expected to set
`Trailer` header appropriately if they will use this; CP will not generate
that header as it can't know if trailer headers will be present or not,
and in any case, `Trailer` is SHOULD not MUST feature.

Because WSGI doesn't appear to have this concept, and I didn't want to
change existing API definitions, I used custom `cherrypy.trailer_headers`
element in `environ` object for this. It seems there's precedent for this
type of extension, but I can change this if you feel some other solution
would be better.

I also modified `test_conn.py` to include tests on this. Please note that
it's impossible to actually test the trailer headers arrive in the test
framework because `httplib.HTTPResponse` discards trailer headers. I used
curl and strace to verify the trailer is transmitted and processed
correctly. All existing tests pass without additional failures.

--
Ticket URL: <http://www.cherrypy.org/ticket/1097>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework
Reply all
Reply to author
Forward
0 new messages