JAVA里HTTP连接为什么使用Range报头没有效果?

2025-03-07 06:48:02
推荐回答(1个)
回答1:

URL url = new URL("http://www.mydomain.com/down.zip";);
HttpURLConnection httpConnection=(HttpURLConnection) url.openConnection();
//设置断点续传的开始位置
httpConnection.setRequestProperty("RANGE","bytes=10000");
//设置请求信息
httpConnection.setRequestProperty("GET","/down.zip HTTP/1.1");
//设置接受信息
httpConnection.setRequestProperty("Accept","image/gif,image/x-xbitmap,application/
msword,*/*");
//设置连接信息
httpConnection.setRequestProperty("Connection","Keep-Alive");
//获得输入流
InputStream input = httpConnection.getInputStream();