使用FTP或HTTP协议的下载软件支持断点续传和多线程的协议基础是:
FTP用的是REST和SIZE;HTTP用的是Range。
1、FTP实现断点续传的协议基础
REST (有的服务器可能不支持此命令)
Syntax: REST position
Sets the point at which a file transfer should start; useful for resuming interrupted transfers. For nonstructured files, this is simply a decimal number. This command must immediately precede a data transfer command (RETR or STOR .ly); i.e. it must come after any PORT or PASV command.
2、FTP实现多线程下载同一个大文件的协议基础
SIZE
Syntax: SIZE remote-filename
Returns the size of the remote file as a decimal number.
3、raw FTP commands
[url]http://www.nsftools.com/tips/RawFTP.htm#SIZE[/url]
[url]http://www.ietf.org/rfc/rfc959.txt[/url]
4、HTTP实现断点续传和多线程下载同一个大文件的协议基础
Range
HTTP retri. requests using conditional or unconditional GET methods MAY request .e or more sub-ranges of the entity, instead of the entire entity, using the Range request header, which applies to the entity returned as the result of the request:
Range = "Range" ":" ranges-specifier
A server MAY ignore the Range header. However, HTTP/1.1 origin servers and intermediate caches ought to support byte ranges when possible, since Range supports efficient recovery from partially failed transfers, and supports efficient partial retri. of large entities.
If the server supports the Range header and the specified range or ranges are appropriate for the entity:
- The presence of a Range header in an unconditional GET modifies
what is returned if the GET is otherwise successful. In other
words, the response carries a status code of 206 (Partial
Content) instead of 200 (OK).
- The presence of a Range header in a conditional GET (a request
using .e or both of If-Modified-Since and If-None-Match, or
.e or both of If-Unmodified-Since and If-Match) modifies what
is returned if the GET is otherwise successful and the
condition is true. It does not affect the 304 (Not Modified)
response returned if the conditional is false.
In some cases, it might be more appropriate to use the If-Range header (see section 14.27) in addition to the Range header.
If a proxy that supports ranges receives a Range request, forwards the request to an inbound server, and receives an entire entity in reply, it SHOULD .ly return the requested range to its client. It SHOULD store the entire received response in its cache if that is consistent with its cache allocation policies.
5、Hypertext Transfer Protocol -- HTTP/1.1
[url]http://www.w3.org/Protocols/rfc2616/rfc2616.html[/url]
FTP用的是REST和SIZE;HTTP用的是Range。
1、FTP实现断点续传的协议基础
REST (有的服务器可能不支持此命令)
Syntax: REST position
Sets the point at which a file transfer should start; useful for resuming interrupted transfers. For nonstructured files, this is simply a decimal number. This command must immediately precede a data transfer command (RETR or STOR .ly); i.e. it must come after any PORT or PASV command.
2、FTP实现多线程下载同一个大文件的协议基础
SIZE
Syntax: SIZE remote-filename
Returns the size of the remote file as a decimal number.
3、raw FTP commands
[url]http://www.nsftools.com/tips/RawFTP.htm#SIZE[/url]
[url]http://www.ietf.org/rfc/rfc959.txt[/url]
4、HTTP实现断点续传和多线程下载同一个大文件的协议基础
Range
HTTP retri. requests using conditional or unconditional GET methods MAY request .e or more sub-ranges of the entity, instead of the entire entity, using the Range request header, which applies to the entity returned as the result of the request:
Range = "Range" ":" ranges-specifier
A server MAY ignore the Range header. However, HTTP/1.1 origin servers and intermediate caches ought to support byte ranges when possible, since Range supports efficient recovery from partially failed transfers, and supports efficient partial retri. of large entities.
If the server supports the Range header and the specified range or ranges are appropriate for the entity:
- The presence of a Range header in an unconditional GET modifies
what is returned if the GET is otherwise successful. In other
words, the response carries a status code of 206 (Partial
Content) instead of 200 (OK).
- The presence of a Range header in a conditional GET (a request
using .e or both of If-Modified-Since and If-None-Match, or
.e or both of If-Unmodified-Since and If-Match) modifies what
is returned if the GET is otherwise successful and the
condition is true. It does not affect the 304 (Not Modified)
response returned if the conditional is false.
In some cases, it might be more appropriate to use the If-Range header (see section 14.27) in addition to the Range header.
If a proxy that supports ranges receives a Range request, forwards the request to an inbound server, and receives an entire entity in reply, it SHOULD .ly return the requested range to its client. It SHOULD store the entire received response in its cache if that is consistent with its cache allocation policies.
5、Hypertext Transfer Protocol -- HTTP/1.1
[url]http://www.w3.org/Protocols/rfc2616/rfc2616.html[/url]
本文转自 h2appy 51CTO博客,原文链接:http://blog.51cto.com/h2appy/138512,如需转载请自行联系原作者