Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

After upgrade, existing cached responses returned with responseStatusCode 0 instead of 200 #188

gbuesing opened this Issue May 16, 2011 · 1 comment


None yet
2 participants

After I upgraded to the latest ASI, existing responses cached in the permanent store were returned to my app with status code 0, which broke how my app handles responses (I'm presenting an error message if the response is not a 2xx).

It appears that this change has caused this issue -- "ASIDownloadCache now stores the response status code in a custom header in the cached headers dictionary, and requests will have their response status code set to this when they are pulled from the cache"


I'm guessing the solution for this would be, for legacy responses cached without a status code, the status code should be returned as a 200?


pokeb commented May 28, 2011

Hi Geoff

Thanks for your report.

This should fix the problem: (in useDataFromCache in ASIHTTPRequest.m)

NSNumber *code = [headers objectForKey:@"X-ASIHTTPRequest-Response-Status-Code"];
if (code) {
    [self setResponseStatusCode:[code intValue]];

// For legacy data cached before ASIHTTPRequest stored the response code in X-ASIHTTPRequest-Response-Status-Code 
} else {
    [self setResponseStatusCode:200];

I haven't committed this because ASIDownloadCache has been under active development for some time, and backwards compatibility has broken more than once in the past. If others feel strongly that I should add this, please add your vote, and I'll get this done.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment