Iphone AsiHttpRequest 身份验证 RESTService

发布于 2024-11-05 17:55:41 字数 1796 浏览 0 评论 0原文

我尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花伊自在美 2024-11-12 17:55:41

看起来可能不是您的应用程序有问题,而是您尝试连接的服务器有问题 - 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文