[Catalyst] Re: returning empty 200 response
pagaltzis at gmx.de
Sun Oct 28 12:49:35 GMT 2007
* Devo Coran <devincoran at yahoo.com> [2007-10-26 21:30]:
> This is probably a basic question but after playing
> around for a few hours and going through the docs I
> haven't been able to figure it out.
that’s because you’re looking at the wrong layer. :-)
> Appreciate it if maybe someone could point me in the right
> direction for docs.
> Basically I'm doing an ajax save from a text area, so all I
> care about is that I get a 200 back from the framework I don't
> need a body, my text hasn't gone anywhere.
You want 204, not 200; cf. RFC 2616 sec. 10.2.5:
== 204 No Content ==
The server has fulfilled the request but does not need to
return an entity-body, and might want to return updated
metainformation. […] If the client is a user agent, it SHOULD
NOT change its document view from that which caused the
request to be sent. This response is primarily intended to
allow input for actions to take place without causing a
change to the user agent's active document view […] The 204
response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields.
Note that RenderView will just DWYM if you set the status to 204
(cf. Jonathan’s reply), leaving the body empty and skipping the
template rendering phase with no further action on your part.
Some unsolicited advice, not really addressed at you in
particular: anyone who develops web apps should take the time at
some point to read RFC 2616, the HTTP specification, in full. It
is pretty modest in length and easily comprehensible, if a bit
dry as specs are wont to be. (Make sure to understand how MAY,
SHOULD and MUST are used in RFCs though; they are defined in
RFC 2119 (which is *very* short).) HTTP is not merely a low-layer
implementation detail like TCP: it’s an application protocol.
Know your way around it well, and know how the concepts of the
framework you use translate to it.
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Catalyst