iOS - NSURLConnection - 连接到服务器并获取 Nonce

发布于 2024-12-18 12:30:25 字数 959 浏览 3 评论 0原文

我正在编写 iOS 应用程序。 有一个与某些房地产相关的服务器。 我必须向服务器发送以下请求来获取 Nonce。

GET /ptest/login HTTP/1.1 
Method: GET 
User-Agent: MRIS API 
Testing Tool/2.0 
Rets-Version: RETS/1.7 
Accept: */* 
Host: ptest.mris.com:6103 
Connection: keep-alive

我使用 ASI HTTP 和以下代码来发布:

[self setRequest:[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"/ptest/login"]]];
[request addRequestHeader:@"User-Agent" value:@"CARETS-General/1.0"];
[request addRequestHeader:@"Rets-Version" value:@"1.7"];
[request addRequestHeader:@"Connection" value:@"keep-alive"];
[request addRequestHeader:@"Accept" value:@"*/*"];
[request addRequestHeader:@"Host" value:"ptest.mris.com:6103"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
[request startAsynchronous];   

我得到的响应是
错误:无法启动 HTTP 连接

有人能指出我如何建立成功的连接吗?

I'm writing iOS application.
There's a server related to some real estate.
I've to send the following request to server to get the Nonce.

GET /ptest/login HTTP/1.1 
Method: GET 
User-Agent: MRIS API 
Testing Tool/2.0 
Rets-Version: RETS/1.7 
Accept: */* 
Host: ptest.mris.com:6103 
Connection: keep-alive

I'm using ASI HTTP with following code to post:

[self setRequest:[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"/ptest/login"]]];
[request addRequestHeader:@"User-Agent" value:@"CARETS-General/1.0"];
[request addRequestHeader:@"Rets-Version" value:@"1.7"];
[request addRequestHeader:@"Connection" value:@"keep-alive"];
[request addRequestHeader:@"Accept" value:@"*/*"];
[request addRequestHeader:@"Host" value:"ptest.mris.com:6103"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
[request startAsynchronous];   

The response that I'm getting is
Error: Unable to start HTTP connection

Can some one point me how to establish successful connection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

千柳 2024-12-25 12:30:25

我找到了。
随机数值在“响应标头”中返回。

I found it.
The nonce value is being returned in "Response Header".

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