来自java.com的HTTP响应是
HTTP/1.1 200 OKServer: Sun-Java-System-Web-Server/7.0Date: Wed, 23 Feb 2011 11:07:44 GMTContent-Type: text/html;charset=UTF-8Set-cookie: JSESSIonID=B62F3DFB233BB2806018EC721F6C3FD7; Path=/Content-Encoding: gzipVary: accept-encodingTransfer-Encoding: chunked
维基百科的HTTP响应是
HTTP/1.0 200 OKDate: Wed, 23 Feb 2011 10:18:56 GMTServer: ApacheCache-Control: private, s-maxage=0, max-age=0, must-revalidateContent-Language: enVary: Accept-Encoding,cookieLast-Modified: Fri, 18 Feb 2011 00:23:59 GMTContent-Encoding: gzipContent-Length: 24905Content-Type: text/html; charset=UTF-8Age: 2984X-Cache: HIT from sq61.wikimedia.org, MISS from sq38.wikimedia.orgX-Cache-Lookup: HIT from sq61.wikimedia.org:3128, MISS from sq38.wikimedia.org:80Connection: keep-alive
如您所见,http://java.com/en/about/的HTTP响应不包含Content-
Length标头,内容是分块的。
因此,getLength()返回-1。



