Callback functions with httplib.HTTPSConnection

David Morris dvmorris at gmail.com
Tue Aug 14 11:12:50 EDT 2007


Is there a way to give a progress or status message while a file it
uploading using httplib.HTTPSConnection? Here is some sample code that I
would like to add a progress message to when run from the commandline:

server = httplib.HTTPSConnection(upload_host)
 server.request('POST', upload_uri, body, headers)
 resp = server.getresponse()
 server.close()

 if resp.status == 201:
   location = resp.getheader('Location', None)
 else:
   location = None
 return resp.status, resp.reason, location

It looks like ftplib has support for callback functions for things like
listing the contents of a directory, but I don't see callback support
anywhere in httplib. Would it only be possible to show an estimated duration
based on file size, or would the better answer be to break the file up into
chunks? I'm pretty new to Python, so I'm not quite sure how to handle
something like this...

Thanks for the help,

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070814/56003ecc/attachment.html>


More information about the Python-list mailing list