iPhone POST请求截断字符串

iPhone POST请求截断字符串,iphone,xcode,post,nsstring,nsmutableurlrequest,Iphone,Xcode,Post,Nsstring,Nsmutableurlrequest,当我尝试向特定站点发送POST请求时,我尝试发送的字符串被切断。当我在Xcode中检查字符串的长度时,它大约有55000个字符长。网站上收到的字符数量约为4500个。 这是我的代码: -(IBAction)convert { NSString *rosterText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerHTML"]; NSString *params = [[NSS

当我尝试向特定站点发送POST请求时,我尝试发送的字符串被切断。当我在Xcode中检查字符串的长度时,它大约有55000个字符长。网站上收到的字符数量约为4500个。 这是我的代码:

-(IBAction)convert {

NSString *rosterText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerHTML"];

NSString *params = [[NSString alloc] initWithFormat:@"roster=%@", rosterText];

NSString *paramsLength = [NSString stringWithFormat:@"%d", [params length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.thesite/index.php"]];

[request setHTTPMethod:@"POST"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];

[request setValue:paramsLength forHTTPHeaderField:@"Content-Length"];

[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];

NSLog(@"length = %@",paramsLength);

[webView loadRequest:request]; 

[params release];

[request release];
}

我在网站上有一个表单,您可以手动插入字符串,并且一切正常,因此在我看来,POST数据的编码中出现了一些问题

有人知道这里出了什么问题吗?我就是想不通


非常感谢

我不确定出了什么问题,但我建议您使用

ASIHTTPRequest是一个易于使用的 围绕CFNetwork API的包装器 使一些更乏味的方面 与web服务器通信的方法 更容易的。它是用Objective-C编写的 并且可以在Mac OS X和iPhone中使用 应用程序


现在真是魅力四射!谢谢!