This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alien_life_form
Recipients
Date 2004-11-12.15:48:57
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Greetings.

The attached patch makes it possible to use a file-like
object in httplib requests (useful to PUT large files
without exhausting the machine memory - think a DAV
server).

The supplied object must be able to read().

If Content-Length support is desired, the body object
must either have a  __length__ method (so len(body)
works)  OR have a stat-able "name" property (file
objects are in the second category).

Having applied this patch the following works:

   import httplib
    import base64
    hh={}
    auth = base64.encodestring("%s:%s" %
("guest","guest")).rstrip()
    hh['Authorization']='Basic %s' % auth
    conn=HTTPConnection('localhost',8080)
    conn.debuglevel=99
    thestream=open(r'\tmp\huge.pdf','rb')
    conn.request('PUT',
                 '/dav/streamed',
                 thestream,hh)
    thestream.close()
    rsp=conn.getresponse()
    print
rsp.status,"-",rsp.reason,repr(rsp.msg.dict),rsp.read()
    conn.close()


Opening in 'rb' mode - on windoze - is important for
this to work, or the content length header will be
wrong,  which is probably BAD.
 
Alessandro Forghieri

 
History
Date User Action Args
2007-08-23 15:40:40adminlinkissue1065257 messages
2007-08-23 15:40:40admincreate