I am trying to use the status to see if there is an error in C++ XPCOM component in my observer class on Mac.
OnStateChange(
nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRUint32 aStateFlags,
nsresult aStatus)
{
}
In proxy environment the aStatus parameter is always true though the browser fails to load the page.
In non-proxy environments it gives the proper value (error) in status.
You can see it if you try accessing http://10.1.3.3/ (some random IP). With a proxy the status is zero (success) and without a proxy you get an error value.
Should some parameters be set to get the proper error value?
This is the expected behavior if you use an HTTP proxy. A non-zero
aStatusmeans “didn’t get any response because of some error”. On the other hand, a zeroaStatusvalue means “there was some response, checknsIHttpChannel.responseStatusto see whether the request was successful”. That’s what you get if the server responds with “404 Not Found” for example –aStatuswill be zero (you got a response back) butnsIHttpChannel.responseStatuswill be 404.It’s the same with an HTTP proxy because the proxy will always send a response back, probably “502 Bad Gateway” if it couldn’t connect to the server. That’s what the browser gets so
aStatuswill be zero andnsIHttpChannel.responseStatuswill be 502. So in you code you should do something like this: