[Python-Dev] Re: urllib.urlretrieve

Fredrik Lundh fredrik at pythonware.com
Fri Aug 27 09:45:02 CEST 2004


David Abrahams wrote:

>> sourceforge is known to have reliability problems when downloading
>> large files.  here's a wget session on my machine (okay, it's not a silent
>> truncation, but SF is clearly not well):
>
> Okay, that tells me something... but shouldn't urllib throw an
> exception in case of a problem... or shouldn't it do something to
> retry?

from the HTTP speification:

    HTTP/1.1 user agents MUST notify the user when an invalid
    length is received and detected.

is urllib a user agent?   or is that better left to your application?

    file, headers = urllib.urlretrieve(...)
    if os.path.getsize(file) != int(headers.get("content-length", 0)):
        print "oops!"

</F> 





More information about the Python-Dev mailing list