I’m developing a firefox addon which performs actions if a statuscode is a 4xx or 5xx error.
It works quite well as it is now, but it doesn’t take actions if the error code is a 408.
Firefox gives me an error but the error never reaches my extension.
My httpobserver looks like this:
observe: function(aSubject, aTopic, aData)
{
if (aTopic == 'http-on-examine-response')
{
httpstatus = aSubject.responseStatus.toString();
if(httpstatus.substr(0,1) in {4:1,5:1})
{
...
I also tried to put an alert box after the httpstatus is set (right before the if) it alerts all codes it gets except for the 408 error.
Does anybody know how to do this? Thanks in advance!
What you mean is most likely not “408 Timed Out” HTTP response (that would happen e.g. if a proxy server cannot reach the server) but
NS_ERROR_NET_TIMEOUT– an error generated by Gecko if it cannot reach the server.http-on-examine-responsenotification is only triggered if a response from server is received, forNS_ERROR_NET_TIMEOUTthis is not the case.Unfortunately, listening to such errors isn’t possible by means of observers. You can use a progress listener, whenever a load stops its
onStateChangemethod will be called withaStateFlagsincludingLOAD_STOPflag andaStatusbeing the channel status (NS_ERROR_NET_TIMEOUTin this case).