I have an iPad app which loads a plist from a server fine on a UIWebView but when I try to get it as response string from the server, it returns a http status code 400 with respon开发者_如何学Cse string as Request Error (invalid_request).
It happens only in middle east countries. One user from United Arab Emirates confirmed about the issue to whom I sent an adhoc build for testing. App returns a status code of 400 but the plist loads fine on UIWebView.
I had been trying for 2 different servers - AWS server and another hosted in USA. For both the servers, it gives the same status code.
Can anyone give suggestions as to why it should happen?
Here's a part of the code:
.....
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[request addRequestHeader:@"Accept-Encoding" value:@"text/xml;charset=utf-8"];
[request setRequestMethod:@"GET"];
[request setDelegate:self];
[request setDidFinishSelector: @selector(gotTheResponse:)];
[request setDidFailSelector: @selector(requestFailed:)];
[networkQueue addOperation: request];
[networkQueue go];
....
I'm not sure if this is the problem or not, but this line:
[request addRequestHeader:@"Accept-Encoding" value:@"text/xml;charset=utf-8"];
is setting an invalid value for the Accept-Encoding header I believe. More usual values would be "compress, gzip", and you shouldn't really need to set it yourself. If you want text/xml returned by the server, that should go into an "Accept" header - though you may not need it at all depending on the server setup.
It's also unusual to use a Content-Type header on a GET request, is there a reason you're adding that?
One final possibility would be if the URL contains unusual characters, potentially that could cause any proxy server to return an error.
精彩评论