NSMutableURLRequest带有URLencode的POST字符串数据,返回“414请求URI太大”
当我使用NSMutableURLRequest向URL字符串数据发送URLencode时,返回“414 Request-URI太大”,我该怎么办? 返回错误消息为如下:NSMutableURLRequest带有URLencode的POST字符串数据,返回“414请求URI太大”
<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]];
urlstr不能既URL和POST数据必须在拆呢还是先&到URL和POST数据。?。
hi ott,如何分割它?或第一个&到URL和POST数据? http://*.*.*/m/?r = Iphone/Suggest&C =%@&PN =%@&Flag =%@并且Suggest&C =%@数据太长,我如何拆分? –
使用[urlStr componentsSeperatedByString:@“&”]将其拆分为一个数组,array [0]是url。然后再次使用[array componentsJoinedByString:@“&”]从array [1] .. array [n]重建后数据。当然,如果您在构建后期数据时只是省略了网址,那就更容易了。 –
你的URL有多长? –
我用[urlStr长度]得到的长度是42833. –
为什么这么大的一串? – Zigglzworth