带有URLencode的NSMutableURLRequest POST字符串数据,返回“414 Request-URI Too Large”

时间:2011-10-01 16:48:12

标签: iphone

当我使用NSMutableURLRequest使用URLencode POST字符串数据时,返回“414 Request-URI Too Large”,我该怎么办? 返回错误消息如下:

<html>
<head><title>414 Request-URI Too Large</title></head>
<body bgcolor="white">
<center><h1>414 Request-URI Too Large</h1></center>
<hr><center>nginx/1.0.6</center>
</body>
</html>

我使用NSMutableURLRequest设置如下:

NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[urlStr dataUsingEncoding:NSUTF8StringEncoding]];

1 个答案:

答案 0 :(得分:0)

urlstr不能同时包含URL和POST数据。你必须拆分它吗?或者第一个&amp;到URL和POST数据。