Size of a remote URL

Peter Hansen peter at
Mon Aug 30 22:06:26 CEST 2004

Justin wrote:

> Ok so the problem is that my code is not requesting the headers
> properly.  I get back.  Just that.  I don't know what the difference is
> between the IE request and mine
> \ Date: Mon, 30 Aug 2004 19:36:20 GMT
> Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.12
> OpenSSL/0.9.6b DAV/
> 1.0.3 PHP/4.3.2 mod_perl/1.26
> Connection: close
> Content-Type: text/html; charset=iso-8859-1
> My code:
> for y in linklisttype:
> w = urlopen(y)
> z =
> x = z.getheader("Content-Length")
> file_sizes.append(x)
> Is there a better method for getting headers than urlopen?

Better how?  urlopen actually works when the Content-Length
header is provided.  If it doesn't, it's a bug in Python.
Can you or can you not provide an instance of a URL which
does not provide a Content-Length header using your above
code when IE in fact appears to get the length?

By the way, the above code works perfectly well when applied
to the first URL you gave above.  Have you got one where
it doesn't?


More information about the Python-list mailing list