Search code examples
objective-ciosasihttprequest

Any idea why asi-http-request has started failing on this code that it used to work on?


Short snippet here (synchronous just for sample, normally we use async and both happen to fail the same way now... Note that url2 is already setup and works fine against our server if I use it manually. Also, please forgive any simple typos as my Mac is being stupid today and refusing to copy/paste, forcing me to retype... Luckily I'm more in need of general "way of doing things" help rather than "fix my syntax" in this case as it used to work, but (without any changes) failed sometime in the last month (possibly with the iOS 6 update). :-)

ASIHTTPRequest *request2=[ASIHTTPRequest requestWithURL:url2];
request2.requestMethod=@"GET";
[request2 addRequestHeader:@"Content-Type" value:@"application/json"];
[request2 setDelegate:self];
[request2 startSynchronous];
NSError *error=[request2 error];

The returned error code is "1", but I can't find an error code list in the asi-http-request docs to find out what it might mean. Also, note that I've updated to the very latest asi-http-request version available (still pretty old though).


Solution

  • That error code is ASIConnectionFailureErrorType (it's an enumeration at the top of ASIHTTPrequest.h).

    Line 188 of ASIHTTPRequest.h says

    // If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information
    

    and the only place it's referenced in code is in ASIHTTPRequest.m, in the handleStreamError method (line 3644).

    So that's where I'd start :)