That is fair enough, but if the controller returns no content (None or "" for instance) would it make sense to not set any Content-Type (and related) headers?
Cheers, Chris On 22/01/2009, at 6:24 AM, Mike Orr wrote: > > Well, Pylons and webob.Response are geared for the normal case of > sending HTML documents. If you do something different, you have to > set all necessary headers yourself. That's what the > redirect/redirect_to() and abort() functions do; change the headers to > match common scenarios. Perhaps abort can be taught that abort(204) > should strip the content-type? I'm not sure it's worth making a > no_content() function for Pylons, though you could make one for your > application. > > --Mike > > On Wed, Jan 21, 2009 at 10:55 AM, Domhnall Walsh > <[email protected]> wrote: >> Personally, I reckon that if a response shouldn't contain any >> content, then >> it stands to reason that a content-type header is pointless (why >> tell the >> browser what type of data the non-existent content has?). As such, >> I'd >> imagine the interpretation is strict but valid. >> >> Regards, >> Domhnall. >> >> 2009/1/21 Chris Miles <[email protected]> >>> >>> I have a simple Pylons controller that responds to PUT requests >>> with a >>> 204 (No Content) status and no entity body. For example (stripped >>> down):: >>> >>> class DataController(BaseController): >>> def test_put(self): >>> do_something() >>> response.status = "204" # No content >>> return None >>> >>> The functional test (using webtest) fails on this action with:: >>> >>> AssertionError: Content-Type header found in a 204 response, which >>> must not return content. >>> >>> because Pylons is including a default Content-Type in the response >>> ("content-type: text/html; charset=utf-8"). >>> >>> I can avoid the error by explicitly removing the Content-Type header >>> from the response (del response.headers['content-type']) but this >>> seems unnecessary. >>> >>> Either Pylons or Webtest are at fault with their understanding of >>> whether a Content-Type header is allowed with a 204 response. >>> >>> In webtest it is lint.py:check_content_type() that enforces a 204 >>> response to contain no Content-Type header. While I agree a >>> Content- >>> Type is unnecessary for a response containing no body, I can't see >>> anywhere in rfc2616 that dictates including a Content-Type header is >>> invalid. >>> >>> Anyone care to make a call one way or the other? Otherwise I'll >>> submit a Webtest ticket/patch. >>> >>> Cheers, >>> Chris Miles >>> >>> >>> >> >> >> >> -- >> Quidquid latine dictum sit, altum sonatur. >> (Whatever is said in Latin sounds profound) >> >>> >> > > > > -- > Mike Orr <[email protected]> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
