【发布时间】:2013-12-04 21:05:29
【问题描述】:
我有一个关于 NSUrlConnection 和 http 会话的问题。 我需要使用 POST 调用 httpS url。 我试过这段代码:
NSString *bodyData = @"selectTipoVeicolo=A&inputTarga=EN784DC";
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.theUrl.com"]];
[postRequest setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
// Designate the request a POST request and specify its body data
[postRequest setHTTPMethod:@"POST"];
[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:postRequest
delegate:self];
[connection start];
但我获得了一个带有此消息的 html 页面:
您的会话已超时。 Web 应用程序存储有关信息 你在服务器上做什么。该信息称为 会话。
Web 服务器必须跟踪很多很多的会话。如果您不活动一段时间 足够长的时间(通常是几分钟),此信息是 为活跃用户腾出空间。
此时您可以重新启动会话以继续。
编辑
服务器响应:
<NSHTTPURLResponse: 0x8ad8400> { URL: theHost.com/http://voas.theHost.com:7777/… } { status code: 200, headers { "Cache-Control" = private; Connection = "Keep-Alive"; "Content-Length" = 2383; "Content-Type" = "text/html;charset=UTF-8"; Date = "Wed, 04 Dec 2013 21:21:52 GMT"; "Keep-Alive" = "timeout=50,max=9"; Server = "Oracle-Application-Server-10g/9.0.4.3.0 Oracle-HTTP-Server OracleAS-Web-Cache-10g/9.0.4.3.0 (N)"; "Set-Cookie" = "text cookie"; } }
如何避免这个问题?我需要什么?
【问题讨论】:
标签: ios objective-c https http-post nsurlconnection