我拿到了error 1000 (URL bad excess),但我不确定发生了什么。示例网址大致如下所示(在我从Bad URL when requesting with NSURL中读取时,它已经具有编码的百分比):
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 然而,我仍然不确定为什么它不能工作。
如果需要(在百分比编码之前):
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。会以任何方式感谢你的帮助。
发布于 2012-08-31 12:24:39
编辑:编码类型stringByAddingPercentEscapesUsingEncoding可能会解决您的问题
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];希望这能有所帮助
https://stackoverflow.com/questions/12208805
复制相似问题