Mark
Mark

Reputation: 701

NSData dataWithContentsOfURL:options:error: invalid server response

We've generally had success loading JSON-encoded data from our server using:

NSError* error;
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:path] 
                                     options:NSDataReadingUncached
                                       error:&error];

(On a background thread to avoid blocking the main thread.) But, with increasing server load, we've recently seen an invalid but non-error (error == nil) server response of:

 <html><body><script>document.cookie='ggggggg=00268082ggggggg_00268082;
 path=/';window.location.href=window.location.href;</script></body></html>

A retry will often result in successful download of expected JSON-encoded data; the problem appears to be server-side. Three questions:

1) Does anyone recognize this server response?

2) Is our server attempting to create a cookie instead of returning our file/data!?

3) If so, where should we be looking to understand how to avoid this random cookie response from our server?

Upvotes: 0

Views: 471

Answers (1)

Mark
Mark

Reputation: 701

Based on message board traffic, we were able to confirm that the problem could be reproduced by a variety of means (app, browser, or command line) -- the issue had nothing to do with iOS or our application code. We were able to sporadically reproduce the problem from the command line with curl using the form:

curl -D - your-test-url-here -s

After further investigation by our ISP, they determined that the most likely cause of the invalid HTTP response was from their DDoS attack protection. After they reset the affected server(s), the problem was resolved.

Upvotes: 1

Related Questions