"Content-Length" header

Justin justin__devine at hotmail.com
Mon Aug 30 23:15:41 CEST 2004


URL open appears to not want to work unless its paramater is an actual
string spelled out in quotes.  Check out the output to this code.  When
I give urlopen objects instead of pre strings it doens't work
correctly.

print linklisttype

for y in linklisttype:
temp = urlopen(y)
print temp
temp2 = temp.info()
print temp2
temp3 = temp2.getheader("Content-Length")
print temp3
file_sizes.append(temp3)

print file_sizes


#This is the tuple with three urls in it, they all look correct to me

['http://www.ecs.soton.ac.uk/~harnad/temp/ariadne-rae.doc',
'http://www.ecs.soto
n.ac.uk/~harnad/temp/ukparl.doc',
'http://www-admn.csun.edu/systech/techsupport/
procedures/2kcleanup.doc']

#here are the return values for y =0, didn't work
<addinfourl at 25805248 whose fp = <socket._fileobject object at
0x014093B0>>
Date: Mon, 30 Aug 2004 21:10:50 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
None

#same here
<addinfourl at 25805048 whose fp = <socket._fileobject object at
0x01409688>>
Date: Mon, 30 Aug 2004 21:10:53 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
None

#this one worked though i don't know why.  If I paste the URLs they all
work
<addinfourl at 25807968 whose fp = <socket._fileobject object at
0x01409650>>
Server: NetWare-Enterprise-Web-Server/5.1
Date: Mon, 30 Aug 2004 21:10:53 GMT
Content-type: application/msword
Last-modified: Tue, 30 Apr 2002 22:50:08 GMT
Content-length: 297984
Accept-ranges: bytes
Connection: close

297984
[None, None, '297984']




More information about the Python-list mailing list