HTTP1.1 中的状态码与状态描述中有写道
206 Partial Content 客户发送了一个带有Range头的GET请求,服务器完成了它(HTTP 1.1新)。
然后我的客户端代码:
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setRequestProperty("Range", "bytes-" + startIndex + "-" + endIndex);
Log.i("hhh", connection.getResponseCode()+"");//返回值为200
服务器部分代码:
response.setContentType("Application/Octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="
+ fName+"");
FileInputStream is = new FileInputStream(f);
OutputStream os = response.getOutputStream();
int len = 0;
byte[] bs = new byte[2048];
while((len=is.read(bs))>0)
{
os.write(bs, 0, len);
}
response.setCharacterEncoding("UTF-8");
is.close();
os.flush();
os.close();
求解答,谢谢,谢谢