[TYPO3-core] RFC #????:

Martin Kutschker masi-no at spam-typo3.org
Fri Jul 10 12:15:48 CEST 2009


Oliver Hader schrieb:
> Hi Masi,
> 
> Martin Kutschker schrieb:
>> Hi!
>>
>> This is a patch request.
>>
>> Branch: trunk
>>
>> Problem: When an AJAX call fails the error is reported with XML but
>> without setting a different HTTP status. This makes it hard for the
>> calling client code to detect the error condition.
>>
>> Solution: Send the HTTP status 500 when an error occured.
>>
>> Masi
>>
>> PS: Without this change ExtJS would wait forever when TYPO3 sent an XML
>> error message instead of a valid JSON response.
> 
> But then we should consider sending error messages as JSON response as
> well.

This also my opinion send the response in the same format as the
request, but that should be another RFC-

> However, a HTTP 500 error code means the following:
> | The server encountered an unexpected condition which prevented it from
> | fulfilling the request.

When an AJAX script sets the error code not send the requested data (be
it XML or JSON). At least my scripts set the AJAX error flag when
something bad happened.

> The request was fulfilled but a misbehaviour was encountered during
> runtime. A 500 error code should be used only when something crashed or
> whatever - which is not the case here.

How do define a crash? Let's assume the script has problems with it's
data and has to stop processing. So it sets the AJAX error flag. In this
condition it MUST NOT send a status 200. At least not in my opinion.

> However, I'd be fine with using a HTTP header like
> | X-TYPO3-Error: 550 The given command could not be processed

This is pointless. The idea is to send a status that AJAX libs around
the world can interpret as failure without having to have knowledge
about TYPO3.

If you think that 500 is too harsh make a suggestion for another HTTP
header as long as it signifies an error and is distinct from 200.

A real world example:

I was implementing an ExtJS Combobox with a JSON store. My AJAX code
checked it's parameters and was setting the AJAX error (and status 200).
Result: the combo box kept loading and loading. After I changed the code
to 500 the combo box stopped loading. This is what I expect. No extra
code to check for errors when there is a well known mechanism to report
a failure to the client.

Masi


More information about the TYPO3-team-core mailing list