iOS - NSURLConnection - 连接到服务器并获取 Nonce
我正在编写 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了。
随机数值在“响应标头”中返回。
I found it.
The nonce value is being returned in "Response Header".