您的位置:首页 > 理论基础 > 计算机网络

FTP、HTTP断点续传和多线程的协议基础

2009-03-13 12:08 357 查看
使用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
http://www.nsftools.com/tips/RawFTP.htm#SIZE
http://www.ietf.org/rfc/rfc959.txt
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
http://www.w3.org/Protocols/rfc2616/rfc2616.html

本文出自 “GONE WITH THE WIND” 博客,请务必保留此出处http://h2appy.blog.51cto.com/609721/138512
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: