I have an iOS app in which a REST WebService request is made through NSURLConnection. It works fine in all cases except when the service (implemented with .NET - IIS 7) has no data to return. When it has no data, the response shows status 204 alright, and has an empty response body, but it takes a very long time (excess of 45-60 seconds) to trigger the connection:didReceiveResponse delegate.

I noticed that in the C# code, the status code is explicitly set to 204 in these cases, and "null" is returned (which I know is incorrect in itself: 204 responses should return nothing, not even null).

Debugging this WebService with Fiddler, I found a warning stating that there was a mismatch between the response-length header field (which had a value of '4', perhaps from "null"?), and the response-body, which of course was empty.

Now this whole issue (of the NSURLConnection delegates taking a long time to get triggered) was fixed when I stopped setting the status code to 204, but the strange part is, this only happened in my production environment, and not in the staging environment.

Is there any reasonable explanation for this? Perhaps some IIS setting?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow