On Wed, Sep 03, 2003 at 04:35:37PM -0400, John Belmonte wrote:
> Hello,
>
> I am designing a web application using Quixote and the REST architecture
> style. Sometimes I'd like to generate a response that has no body, for
> example:
>
> HTTP/1.1 201 Created
> Location: http://example.net/some-resource/555
>
> However, the Quixote framework does not allow HTTP request handlers to
> return None. From Publisher.try_publish():
>
> if output is None:
> raise RuntimeError, 'callable %s returned None' % repr(object)
>
> In light of the fact that it's reasonable to return no body, what is the
> purpose of this exception? Is it necessary?
It catches some programming errors.
> I know that I can have my handler return an empty string, but this will
> cause the Content-type and Content-length headers to be set due to the
> way HTTPResponse works.
No, returning the empty string will leave 'response.body' equal to None.
However, I have noticed that with Apache and mod_scgi I still get:
HTTP/1.1 200 OK
Date: Wed, 03 Sep 2003 20:48:20 GMT
Server: Apache/1.3.27
Expires: -1
Connection: close
Content-Type: text/plain
I'm pretty sure the Connection and Content-Type headers have been added
by Apache, not by Quixote. I just tested the Medusa server and I get
this:
HTTP/1.0 200 OK
Date: Wed, 03 Sep 2003 20:52:44 GMT
Status: 200 OK
Expires: -1
Server: Medusa/1.9
So, I think returning an empty string is what you want.
Neil