I have been working with Async to build an inhouse web app, we have
ended up using the return codes to implement some interesting
behaviour in our clients.
MochiKit is just one of the clients that uses the web service and some
of our other processes (robots essentially) look for return codes to
act upon. One of these codes is 202 - Accepted. We use this in
response to requests that fire off long running processes in the
server. The server responds with a 202 saying that it is now running
the process and includes a location header to indicate where the
client should go to get updates on the current status of the process.
By default MochiKit doesn't treat a 202 as a success.
I have read the other messages on the list about this but there didn't
seem to be a consensus of opinion on why the current codes are
considered successes but others aren't.
I know that I could add an errback that redirects requests with 202 to
the success callback but it seems like a hack. I have changed the
following in my version of MochiKit;
From:
// 200 is OK, 201 is CREATED, 204 is NO CONTENT
// 304 is NOT MODIFIED, 1223 is apparently a bug in IE
if (status == 200 || status == 201 || status == 204 ||
status == 304 || status == 1223) {
d.callback(this);
To:
// Anything in the 200 range is a success.
// 304 is NOT MODIFIED, 1223 is apparently a bug in IE
if (((199 < status) && (status < 300)) ||
(status == 304) ||
(status == 1223)) //..IE - sigh..
{
d.callback(this);
}
This new code looks like it is treating non-existent codes as
successes (for example 242 would be treated as a success), however the
RFC says that anything in that range is a success (well from my
reading anyway*) so I don't think that MochiKit should be putting its
own definition of what a success is on top of what the RFC says.
Any thoughts by anyone? Any chance MochiKit will change to work like
this?
Regards, Simon Cusack.
* The relevant bit of the RFC http://www.faqs.org/rfcs/rfc2616.html
is
10.2 Successful 2xx
This class of status code indicates that the client's request was
successfully received, understood, and accepted.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---