| 如果Content Length 在头文件中没有描述 |

暂时还没有解决方案
| 如果Content Long在头文件中有描述 |

一款非常漂亮的酒类网站,以红色为主调,页面干净清洁、一目了然,非常适合卖红酒中小企业的朋友 mttshop打造精致、简单、易用、免费的商城 系统要求:IIS5.1以后,必须安装.net 3.5 安装步骤: 1、下载完成后,直接解压文件mb003.rar 2、附加数据库:解压后的可以找一个叫db的文件夹,打开后直接附加就可以,支持SQL 2000、2005、2008 3、配置web.co
0
方案一:
立即学习“Java免费学习笔记(深入)”;
伪装成浏览器
conn.setRequestProperty("User-Agent", " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");代码中加入代理
String host = "127.0.0.1";
String port = "8888";
setProxy(host, port);
public static void setProxy(String host, String port) {
System.setProperty("proxySet", "true");
System.setProperty("proxyHost", host);
System.setProperty("proxyPort", port);
}
方案二:
加入以下属性,让服务器不要gzip方式压缩:
Java Doc 有对此的描述:
By default, this implementation of HttpURLConnection requests that servers use gzip compression. Since getContentLength() returns the number of bytes transmitted, you cannot use that method to predict how many bytes can be read from getInputStream(). Instead, read that stream until it is exhausted: whenread() returns -1.
conn.setRequestProperty("Accept-Encoding", "identity");
以上就是JAVA下载中getContentLength()一直为-1的一些思路的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号