facebook/tornado — Issue #416: Control over automatic Content-Type and ETag generation
Author: MrJoes
Created: 2011-12-08 13:23:36+00:00
State: open

Hi,

Right now, Tornado will output two headers:
1. Content-Type, which is set to text/html by default
2. ETag which will be calculated for the response by the Tornado.

1. Content-Type is not required for all responses. For example, according to RFC, for 304:

http://tools.ietf.org/html/rfc2616#section-10.3.5

"... the response MUST NOT include other entity-headers; this prevents
inconsistencies between cached entity-bodies and updated headers."

This is, probably, not a big deal, but our application fails on some HTTP unittests.
Can be worked around by handing ETag logic manually and sending 304 response explicity, while removing 'Content-Type' from self._headers collection.

Any better way to do it?

2. ETag should be optional as well. For long polling, especially for GET requests, application will output all kind of headers that should prevent caching of the response on the client side. So, there's no need to spend CPU cycles calculating ETag. While I can suppress this by setting empty ETag header value (which will be sent out), that's probably not right solution.

Thanks,
Serge.