开发者

ASIHttpRequest Response Data/Header Null when Receiving 401

The response data and header fields of ASIHTTPRequest are always null whenever the server returns a 401.

I can only read the status code and NSError code which is set to ASIAuthenticationErrorType. I'm using Charles Web Proxy to sniff the traffic. I can clearly see that the server is returning a non-empty response body.

I've tried implementing the authenticationNeededForRequest: delegate to see if the response data is null. However, this delegate method never gets called.

Here's the code I'm using to initialize the network queue:

networkQueue = [[ASINetworkQueue alloc] init];
[networkQueue setDelegate:self];
[networkQueue setRequestDidFinishSelector:@selector(requestDidFinish:)];
[networkQueue setRequestDidFailSelector:@selector(requestDidFail:)];

And to send the request

ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL:apiURL];
request.delegate = self;
request.userInfo  = userInfo;
[request s开发者_运维技巧etRequestMethod:method];
[networkQueue addOperation:request];
[networkQueue go];

Thank you!


Apparently, this was a bug in previous versions of ASIHttpRequest. It should be fixed on the current version.


If you have implemented the delegate method -(void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data

Then, responseData will be null. Because the API will handover the data handling to the application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜