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

简介:
使用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]









本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/138512,如需转载请自行联系原作者
目录
相关文章
|
18天前
|
网络协议 Linux iOS开发
推荐:实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求
推荐:实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求
38 1
|
1月前
|
网络协议 Linux
HTTP协议基本原理简介(二)
HTTP协议基本原理简介(二)
23 1
|
1月前
|
前端开发
webpack如何设置devServer启动项目为https协议
webpack如何设置devServer启动项目为https协议
136 0
|
1月前
|
缓存 前端开发
HTTP协议基本原理简介(三)
HTTP协议基本原理简介(三)
14 1
|
1月前
File和FTP和HTTP软件配置
File和FTP和HTTP软件配置
|
2天前
|
缓存 网络协议
【计算机协议】第一章——HTTP协议详解
【计算机协议】第一章——HTTP协议详解
|
3天前
|
网络协议 Java API
深度剖析:Java网络编程中的TCP/IP与HTTP协议实践
【4月更文挑战第17天】Java网络编程重在TCP/IP和HTTP协议的应用。TCP提供可靠数据传输,通过Socket和ServerSocket实现;HTTP用于Web服务,常借助HttpURLConnection或Apache HttpClient。两者结合,构成网络服务基础。Java有多种高级API和框架(如Netty、Spring Boot)简化开发,助力高效、高并发的网络通信。
|
6天前
|
缓存 安全 网络协议
Http协议是什么
【4月更文挑战第12天】HTTP是用于从WWW服务器传输超文本到浏览器的协议,基于TCP/IP,特点包括无连接、无状态、面向对象、无阻塞和可缓存。它的工作原理是客户端发送请求,服务器处理后返回响应。自1989年创建以来,HTTP已发展支持多媒体内容传输,并通过HTTPS提供安全保护。学习更多可参考计算机网络技术文献。
15 6
|
8天前
|
存储 JSON 前端开发
网络原理(4)HTTP协议(下)
网络原理(4)HTTP协议
23 0
|
18天前
|
XML JSON JavaScript
推荐一个比较好用的c++版本http协议库-cpp-httplib
推荐一个比较好用的c++版本http协议库-cpp-httplib
36 1