开发者

ASIHTTPRequest authentication needed when not on WiFi, with credentials given

开发者 https://www.devze.com 2023-04-05 21:44 出处:网络
I\'m experiencing some strange behavior with the ASIHTTPRequest. I\'m trying to connect to a website which prompt a user to give his/her credentials when loading the page.

I'm experiencing some strange behavior with the ASIHTTPRequest.

I'm trying to connect to a website which prompt a user to give his/her credentials when loading the page.

To implement this with ASIHTTPRequest i've used the following code:

NSURL *URL = [NSURL URLWithString:@"http://fhict.fontys.nl/Pages/Welkom.aspx"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:URL];

[request setUsername:theUsername];
[request setPassword:thePassword];
[request setDelegate:self];

[request startAsynchronous];

I'm sure the credentials given to the request are correct, and when i'm working on WiFi the request succeeds and the app continues..

But when i'm connected to cellular network, the exact same request gives an error: error:Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x2e8ef0 {NSLocalizedDescription=Authentication needed}

I checked, this same error is given when the credentials are incorrect, but i've double checked them and they are correct!

To fix this I've tried:

  • setting the timeout on 2 minutes (overkill I know but just for testing), this resulted the same error
  • enabled and set bandwidth throttling for WWAN (as described on http://allseeing-i.com/ASIHTTPRequest/How-to-use,开发者_运维问答 search for WWAN), but nothing changed
  • setting enabling shouldPresentCredentialsBeforeChallange and adding basichttpheader to the request, but then also WiFi stopped working..

And then a lot of googling later, still no solution.

I'm a little confused because because on WiFi everything works perfectly,

I hope anyone here can point me in the right direction..


(Answered in a question edit. Converted to a community wiki answer. See What is the appropriate action when the answer to a question is added to the question itself? )

The OP wrote:

I got a tip and changed the url to https, this solved all issues! (I'm leaving the question for if someone experiences the same in the future..)

0

精彩评论

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

关注公众号