【发布时间】:2015-02-04 03:46:47
【问题描述】:
大家好,我的任务是使用 http 请求从本地服务器下载视频文件,我已经可以完成那部分,但他们希望我分段下载视频,这意味着我的请求将是部分的(我会不要用一个请求下载整个文件),问题是我总是收到整个文件。我做错了什么?
代码的重要部分:
socket = new Socket(server, port);
OutputStream os = socket.getOutputStream();
os.write(("GET /Lifted-" + "160" + "p.dat HTTP/1.0\r\n\r\n").getBytes());
os.write(("Range: bytes="+Integer.toString(0)+"-"+Integer.toString((int) (bytedelay))).getBytes());
范围请求的系统输出:
Range: bytes=0-1089889
http 响应的头部:
Last-Modified: Tue, 25 Nov 2014 15:08:03 GMT
Connection: close
Date: Fri, 05 Dec 2014 21:12:31 GMT
Server: Pygmy
Content-Length: 54518444 (whole file)
Content-Type: application/octet-stream
【问题讨论】:
标签: java http networking network-programming network-protocols