All
This is a problem which happens rarely. In fact I had to spend a lot of time to reproduce it but here it is anyways.
I am using ASIHTTPRequest to get some data from my server. I throw error for anything apart from those having responseStatusCode == 200. My server returns some messages.
What I noticed is, that sometimes, depending on my wireless connection (on laptop simulator usage), the ones which needs authentication, ASIHttpRequest returns response of 200, but the responseData is something like the following instead of the messages from my server
<HTML><HEAD><TITLE>Cisco Systems Inc. Web Authentication Redirect</TITLE><META http-equiv="Cache-control" content="no-cache"><META http-equiv="Pragma" content="no-cache"><META http-equiv="Expires" content="-1"><META http-equiv="refresh" content="1; URL=https://webauth-redirect.oracle.com/login.html?redirect=17.22.111.222/scripts_dummy/messagesx.php"></HEAD></HTML>
Is this correct? If the message from the server was not received should not the responseStatusCode be something other than 200
How do I go about handling this kind of situation? meaning after checking responseStatusCode == 200 does not seem to be good enough. This was just an example. In other wireless regions, different garbage is printed out.
UPDATE
Not sure if this has any role to play but I have
request.shouldUseRFC2616RedirectBehaviour = YES; // where request is ASIHTTPRequest
After thinking about this for a few, I’ve come up with an alternate strategy. Content type will be preserved and should not be muddled with.
You should be able to use the content type as a flag that you are receiving a proxy injected page. Set a content type parameter then have your app key off that parameter. Any responses that don’t have the parameter are invalid.
BTW: why are you using a content type of text/html if you don’t properly support HTML processing. Meta refresh should be a part of any HTML engine. If you don’t need HTML, you may want do consider using a data specific content type like XML, YAML, or JSON.
The question has been raised, "is that valid?"
From RFC 2616: 3.7 Media Types
To me, the takeaway from that is don’t send non-standard parameters to older clients. In context, it means you’re safe if you are sending it to any client made since 2000.