首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSURL错误过多

NSURL错误过多
EN

Stack Overflow用户
提问于 2012-08-31 12:14:08
回答 1查看 161关注 0票数 4

我拿到了error 1000 (URL bad excess),但我不确定发生了什么。示例网址大致如下所示(在我从Bad URL when requesting with NSURL中读取时,它已经具有编码的百分比):

代码语言:javascript
复制
http://test1.test.com/X?op=find&base=tpl01&request=%28%28WCL=DVD%20or%20WCL=VCD%20or%20WCL=SDVD%29%20AND%20%28WFM=VM%29%20AND%20%28WIS=19%20or%20WIS=01%29%29 

然而,我仍然不确定为什么它不能工作。

如果需要(在百分比编码之前):

代码语言:javascript
复制
http://test1.test.com/X?op=find&bas=tp01&request=((WCL=DVD or WCL=VCD or WCL=SDVD) AND (WFM=VM) AND (WIS=19 or WIS=01))

在我的互联网连接中,我已经登录了request.URL,但它似乎是空的。我确实插入了我的URL。会以任何方式感谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2012-08-31 12:24:39

编辑:编码类型stringByAddingPercentEscapesUsingEncoding可能会解决您的问题

代码语言:javascript
复制
NSString* urlText = @"http://test1.test.com/X?op=find&bas=tp01&request=((WCL=DVD or WCL=VCD or WCL=SDVD) AND (WFM=VM) AND (WIS=19 or WIS=01))";
urlText = [urlText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString: urlText];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url 
                                                       cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
                                                   timeoutInterval:10];

[request setHTTPMethod: @"GET"];

    NSError *requestError;
NSURLResponse *urlResponse = nil;


NSData *response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];

希望这能有所帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12208805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档