renderer should be able to create a response with no body #709

mmerickel opened this Issue Oct 27, 2012 · 0 comments


None yet

2 participants

Pylons Project member

It's not currently possible for a renderer to return None and cause the http response to return with no body. This means a renderer cannot return a valid 204 response HTTPNoContent.

Possible solutions would be to fix such that if result is None then delete content_length, content_type, and do not set body instead of the current behavior of turning it into an empty string. At the very least the empty string should be b'' instead of unicode, because if a charset is not set on the response a unicode string causes issues.

Or just allow a renderer to return its own response object, overriding request.response.

@mcdonc mcdonc added a commit that closed this issue Nov 3, 2012
@mcdonc mcdonc - In the past if a renderer returned ``None``, the body of the resulting
  response would be set explicitly to the empty string.  Instead, now, the body
  is left unchanged, which allows the renderer to set a body itself by using
  e.g. ``request.response.body = b'foo'``.  The body set by the renderer will
  be unmolested on the way out.  See

Closes #709
@mcdonc mcdonc closed this in a007a4f Nov 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment