我一直在尝试访问来自shoutcast的pls文件数据进行一些测试,但是响应似乎是被禁止的,我得到了403作为响应。以下是代码
NSURL *myurl = [NSURL URLWithString:@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=9944"] ;
//Accept:*/*
NSMutableURLRequest *myrequest = [[NSMutableURLRequest alloc]initWithURL:myurl];
[myrequest setValue:@"*/*" forHTTPHeaderField:@"Accept"];
//NSURL *myurl = [NSURL URLWithString:@"http://www.google.com"];
NSURLConnection *theConnection = [[NSURLConnection alloc]initWithRequest:myrequest delegate:self];在响应中,它显示403,但未收到任何数据。我尝试检查content-type,结果显示为audio/x-scpls
发布于 2010-05-19 22:58:33
在不允许NSURLRequests的情况下,更改提交的用户代理应避免403响应:
[myRequest setValue:userAgent forHTTPHeaderField:@"useragent"];https://stackoverflow.com/questions/2865747
复制相似问题