HTTP 断点续传及其基于 PHP 的实现方案 |
HTTP 断点续传及其基于 PHP 的实现方案 |
2009-09-22 15:54:50, Tue
Post
#1
|
|
猫猫猫 Group: Power Cat Posts: 626 Joined: 2006-12-8 Member No.: 2 |
引用 断点续传是我们现在经常接触的概念,那么HTTP协议是如何支持断点续传的呢。我们先从一个例子来看看。
下面是一个断点续传的例子:(使用NetVampire得到) I01-7-1219:19:23-------------------------Attempt1------------------------- P01-7-1219:19:24Connectingto127.0.0.3... P01-7-1219:19:24Connectedto127.0.0.3[127.0.0.3]S01-7-1219:19:24GET/VS0515AI.EXEHTTP/1.1 S01-7-1219:19:24Connection:close S01-7-1219:19:24Host:127.0.0.3 S01-7-1219:19:24Accept:*/* S01-7-1219:19:24Pragma:no-cache S01-7-1219:19:24Cache-Control:no-cache S01-7-1219:19:24Referer:http://127.0.0.3/ S01-7-1219:19:24User-Agent:Mozilla/4.04[en](Win95;I;Nav) S01-7-1219:19:24 R01-7-1219:19:24HTTP/1.1200OK R01-7-1219:19:24Server:ZeroHttpServer/1.0 R01-7-1219:19:24Date:Thu,12Jul200111:19:24GMT R01-7-1219:19:24Cache-Control:no-cache R01-7-1219:19:24Last-Modified:Tue,30Jan200113:11:30GMT R01-7-1219:19:24Content-Type:application/octet-stream R01-7-1219:19:24Content-Length:15143086 R01-7-1219:19:24Connection:close R01-7-1219:19:24 P01-7-1219:19:25Datatransferstarted I01-7-1219:19:32JobStoppedbyuser I01-7-1219:19:33Received5275648bytesin0:00:07(691435bytes/s) I01-7-1219:19:40-------------------------Attempt2------------------------- P01-7-1219:19:40Connectingto127.0.0.3... P01-7-1219:19:40Connectedto127.0.0.3[127.0.0.3] S01-7-1219:19:40GET/VS0515AI.EXEHTTP/1.1 S01-7-1219:19:40Connection:close S01-7-1219:19:40Host:127.0.0.3 S01-7-1219:19:40Accept:*/* S01-7-1219:19:40Pragma:no-cache S01-7-1219:19:40Cache-Control:no-cache S01-7-1219:19:40Referer:http://127.0.0.3/ S01-7-1219:19:40User-Agent:Mozilla/4.04[en](Win95;I;Nav) S01-7-1219:19:40Range:bytes=5275648- S01-7-1219:19:40 R01-7-1219:19:40HTTP/1.1206PartialContent R01-7-1219:19:40Server:ZeroHttpServer/1.0 R01-7-1219:19:40Date:Thu,12Jul200111:19:40GMT R01-7-1219:19:40Cache-Control:no-cache R01-7-1219:19:40Last-Modified:Tue,30Jan200113:11:30GMT R01-7-1219:19:40Content-Type:application/octet-stream R01-7-1219:19:40Content-Range:bytes5275648-15143085/15143086 R01-7-1219:19:40Content-Length:9867438 R01-7-1219:19:40Connection:close R01-7-1219:19:40 P01-7-1219:19:40Datatransferstarted I01-7-1219:19:41JobStoppedbyuser I01-7-1219:19:41Received1124756bytesin0:00:01(969617bytes/s) 第一次是普通的传输;第二次由于没有传完全,就发出了Range这个头部,从5275648字节开始传输(默认是按字节算),回应使用206状态值,表示现在开始部分传输,回复Content-Length头部,表示传输的部分,用字节记,然后就与普通传输没有区别了。 |
|
|
Lo-Fi Version | Time is now: 2024-12-25 14:41 |