OK, user error as I suspected, but a strange one.
As mentioned, I was using NSURLConnection to try to triangulate the
problem and that was working fine. The actual problem was a typo in
the URL.
I was passing
[NSURL URLWithString:@"http:/
www.google.com/"]
rather than
[NSURL URLWithString:@"
http://www.google.com/"]
to [ASIHTTPRequest requestWithURL:(NSURL*)].
Note the problem is that I missed off a slash in the hier-part of the
URI.
This was failing at the low-level call in ASIHTTPRequest that I
described.
NSURLConnection does not fail when passed in the same invalid URL and
the content is downloaded successfully.
To my mind, it would be preferable for the NSURL class method to
return nil when passed an invalid URL. It might even be a bug in
NSURL, which is allowing a URI to contain a scheme but no authority;
I've not delved into the RFC in sufficient detail.
My question here though would be is there any way of providing a
clearer error message in ASIHTTPRequest?
Cheers,
James
On Aug 12, 4:07 pm, James Abley <
james.ab...@gmail.com> wrote:
> Hi all,
>
> I created a new iPhone project today, added ASIHTTPRequest (running
> off HEAD - b60d4f2f2dec7c47fcb76d8975d69c1f1f714449) to it in the
> usual way and yet I always get an error. Here's the code:
>
> request_ = [[ASIHTTPRequest requestWithURL:[self url]] retain];
> [request_ addRequestHeader:@"User-Agent" value:@"iPhone"];
> [request_ startSynchronous];
>
> if ([request_ error]) {
> NSLog(@"%@:%@ %@", self, NSStringFromSelector(_cmd), [request_
> error]);
> }
>
> The consistent error is:
>
> Error Domain=ASIHTTPRequestErrorDomain Code=6 "Unable to start HTTP
> connection" UserInfo=0x5a1eeb0 {NSLocalizedDescription=Unable to start
> HTTP connection}
>
> I've added some NSURLConnection usage into the same app to ensure that
> there is network connectivity - that is working fine.
>
> I've looked at the code and the failure is around here
>
>
http://github.com/pokeb/asi-http-request/blob/master/Classes/ASIHTTPR...