最近七牛云服务器频繁报 HTTP 416 请求范围无法满足错误,出现改错误的原因是request请求Range设置的范围超出了资源的范围。例如,如果一个图像文件资源有1000个字节,而被请求的范围是500-1500,那就无法满足。
那么设置Range的时候如何获取到服务器上的资源信息呢? 毫无疑问我们需要分析请求头信息。
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
我们打印response观察一下
(lldb) po response
{ URL: http://f1.ichazuo.cn/1507718418684962.mp3 } { status code: 404, headers {
"Access-Control-Allow-Origin" = "*";
"Access-Control-Expose-Headers" = "X-Log, X-Reqid";
"Access-Control-Max-Age" = 2592000;
Connection = "keep-alive";
"Content-Length" = 30;
"Content-Type" = "application/json";
Date = "Wed, 11 Oct 2017 11:33:00 GMT";
EagleId = 3c1ce20115077215791328289e;
Server = Tengine;
"Timing-Allow-Origin" = "*";
Via = "cache8.l2nu16-1[387,404-1280,M], cache10.l2nu16-1[1015,0], kunlun5.cn36[1032,404-0,M], kunlun1.cn36[1045,0]";
"X-Cache" = "MISS TCP_MISS dirn:-2:-2 mlen:-1";
"X-Log" = "mc.g/404;rs4_3.sel:1/not found;rdb.g/no such key;DBD/404;v4.get/Document not found;rwro.get:2/Document not found;RS.dbs:2/Document not found;RS:2/404;mc.g/404;rs4_3.sel:1/not found;rdb.g/no such key;DBD/404