Iphone AsiHttpRequest 身份验证 RESTService
我尝试在 REST 上连接我的应用程序。
我不明白,当我第一次尝试连接时,失败(403)。当我重试时,效果很好! (我目前没有有效的证书)
request = [ASIHTTPRequest requestWithURL:url];
[request setUsername:login];
[request setPassword:password];
[request setDelegate:delegate];
[request setRequestMethod:GET];
[request setValidatesSecureCertificate:NO];
/*I keep my login/pass*/
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request setUseSessionPersistence:YES];
[request setShouldAttemptPersistentConnection:YES];
[request setPersistentConnectionTimeoutSeconds:15.0];
[request setUseCookiePersistence:YES];
/**/
[request startSynchronous];
并记录:
requestUrl:https://urlToLogin
login:user
pwd:pwduser
Starting synchronous request <ASIHTTPRequest: 0x504fc00>
Request #1 will use connection #1
===Used: 0 bytes of bandwidth in last measurement period===
Request <ASIHTTPRequest: 0x504fc00> received response headers
Got a keep-alive header, will keep this connection open for 15.000000 seconds
Request <ASIHTTPRequest: 0x504fc00> finished downloading data (118 bytes)
Request #1 finished using connection #1
codeResponce:403
requestUrl:https://urlToLogin
login:user
pwd:pwduser
Starting synchronous request <ASIHTTPRequest: 0x603a600>
Request #2 will use connection #1
Request <ASIHTTPRequest: 0x603a600> received response headers
Got a keep-alive header, will keep this connection open for 15.000000 seconds
===Used: 138 bytes of bandwidth in last measurement period===
Request <ASIHTTPRequest: 0x603a600> finished downloading data (20 bytes)
Request #2 finished using connection #1
Request finished: <ASIHTTPRequest: 0x603a600>
i try to connect my application on REST.
I don't understand, when i try to connect in a first time, it's fail (403). And when I retry, it is good ! (I don't have valide certificate at this time)
request = [ASIHTTPRequest requestWithURL:url];
[request setUsername:login];
[request setPassword:password];
[request setDelegate:delegate];
[request setRequestMethod:GET];
[request setValidatesSecureCertificate:NO];
/*I keep my login/pass*/
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request setUseSessionPersistence:YES];
[request setShouldAttemptPersistentConnection:YES];
[request setPersistentConnectionTimeoutSeconds:15.0];
[request setUseCookiePersistence:YES];
/**/
[request startSynchronous];
And log:
requestUrl:https://urlToLogin
login:user
pwd:pwduser
Starting synchronous request <ASIHTTPRequest: 0x504fc00>
Request #1 will use connection #1
===Used: 0 bytes of bandwidth in last measurement period===
Request <ASIHTTPRequest: 0x504fc00> received response headers
Got a keep-alive header, will keep this connection open for 15.000000 seconds
Request <ASIHTTPRequest: 0x504fc00> finished downloading data (118 bytes)
Request #1 finished using connection #1
codeResponce:403
requestUrl:https://urlToLogin
login:user
pwd:pwduser
Starting synchronous request <ASIHTTPRequest: 0x603a600>
Request #2 will use connection #1
Request <ASIHTTPRequest: 0x603a600> received response headers
Got a keep-alive header, will keep this connection open for 15.000000 seconds
===Used: 138 bytes of bandwidth in last measurement period===
Request <ASIHTTPRequest: 0x603a600> finished downloading data (20 bytes)
Request #2 finished using connection #1
Request finished: <ASIHTTPRequest: 0x603a600>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来可能不是您的应用程序有问题,而是您尝试连接的服务器有问题 - 403 意味着禁止,因此重试不应修复它。
您想连接到什么?
Looks like it might not be your app that's wrong but the server you're trying to connect to - 403 means forbidden so retrying shouldn't fix it.
What are you trying to connect to?