Http 416错误解决方案
2015-01-07 15:06
148 查看
今天写多线程下载时老报Http416的错误,正常的话应该返回code
206,但是这次却不正常,后来研究了一下,发现如下问题:
以下是错误log:
Server returned HTTP response code: 416 for URL: http://localhost:8080/QQ.exe
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at
java.lang.reflect.Constructor.newInstance(Unknown Source)
at
sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown
Source)
at
java.security.AccessController.doPrivileged(Native Method)
at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at
com.lyc.download.Demo$DownloadThread.run(Demo.java:97)
HTTP response code:
416是由于读取文件时设置的Range有误造成的,具体的说就是下面这行代码有误:
connection.setRequestProperty("Range",
中间的冒号:就是罪魁祸首,敲代码的时候不小心多敲了个冒号造成的;
206,但是这次却不正常,后来研究了一下,发现如下问题:
以下是错误log:
Server returned HTTP response code: 416 for URL: http://localhost:8080/QQ.exe
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at
java.lang.reflect.Constructor.newInstance(Unknown Source)
at
sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown
Source)
at
java.security.AccessController.doPrivileged(Native Method)
at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at
com.lyc.download.Demo$DownloadThread.run(Demo.java:97)
HTTP response code:
416是由于读取文件时设置的Range有误造成的,具体的说就是下面这行代码有误:
connection.setRequestProperty("Range",
"bytes=:"+startIndex+"-"+endIndex);
中间的冒号:就是罪魁祸首,敲代码的时候不小心多敲了个冒号造成的;
相关文章推荐
- Http 416错误解决方案 HTTP response code: 416
- "HTTP 错误 401.1 - 未经授权:访问由于凭据无效被拒绝"的另类解决方案
- HTTP 错误 500.0 - Internal Serve…
- IIS  HTTP 500 错误解决方法
- 请问HTTP 错误 403.9 - 禁止访问:…
- SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, 由于出现错误 00002ef3 
- IIS7.5 报错 HTTP 错误 404.0- Not Found 您要找的资源已被删除、已更名或暂时不可用 解决方案···
- IIS运行不了ASP.NET的解决方案 & HTTP 500 - 内部服务器错误的解决方案
- MyEclipse映射hibernate的错误 An internal error occurred during: "Generating Artifacts"解决方案
- AJAX项目中在IE浏览器上遇到"Internet Explorer无法打开站点,已终止操作"错误解决方案
- 关于"使用注册为 allowDefinition='MachineToApplication' 的节是错误的"的解决方案
- 创建ASP.NET程序时候发生错误"HTTP/1.0500ServerError"的一个解决办法
- Windows 2003不能用 '..' 表示父目录解决方法 (http500错误之一)
- Microsoft JET Database Engine 错误 '80004005' 之解决方案
- HTTP常见错误代码列表汇总及解决方案
- “Request 对象 错误 'ASP 0104 : 80004005'”解决方案
- 解决"HTTP Status 404 - /servlet/HelloServlet"错误
- HTTP 头已经写入到 客户浏览器,错误 'ASP 0156 : 80004005'
- windows server 2003 上“您要访问的网页有问题,无法显示。HTTP 500 - 内部服务器错误。”的问题解决方案!
- Windows XP IIS 500内部错误 解决方案(HTTP 500内部服务器错误) - Fantongking的专栏 - CSDNBlog