"Content-Length" header

Peter Hansen peter at engcorp.com
Mon Aug 30 15:52:05 EDT 2004


Justin wrote:

> I have a program that downloads files from the web.  There are
> instances in which a .info() will not return a "Content-length" header
> to me.  Is ther a way to specifically request this header or FORCE it
> to be sent?  I know there is some way to get the file size for these
> files because Internet Explorer is capable of determining the size on a
> cut / paste of the same exact url.

Was this URL one of them?

c:\>python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on 
win32
 >>> import urllib
 >>> s = 'http://www.ecs.soton.ac.uk/~harnad/Temp/Ariadne-RAE.doc'
 >>> f = urllib.urlopen(s)
 >>> print f.info()
Date: Mon, 30 Aug 2004 19:50:49 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
Last-Modified: Sun, 20 Apr 2003 15:19:42 GMT
ETag: "f10f630-9a800-3ea2ba8e"
Accept-Ranges: bytes
Content-Length: 632832
Connection: close
Content-Type: application/msword


Seems like it works for me.  Maybe you have another URL which doesn't
work for urlopen, but for which IE does actually display a percentage
progress bar?

-Peter



More information about the Python-list mailing list