Issue3243
Created on 2008-06-30 18:01 by catlee, last changed 2009-05-16 20:34 by ajaksu2.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
python-3243.patch
|
catlee,
2008-12-05 16:43
|
Patch for python2.7 |
|
|
|
msg69014 - (view) |
Author: Chris AtLee (catlee) |
Date: 2008-06-30 18:01 |
|
httplib should support requests whose bodies are iterable objects. This
would facilitate doing large file uploads via HTTP since you wouldn't
have to load the entire file into memory to create the request string.
Index: Lib/httplib.py
===================================================================
--- Lib/httplib.py (revision 64600)
+++ Lib/httplib.py (working copy)
@@ -688,7 +688,12 @@
self.__state = _CS_IDLE
def send(self, str):
- """Send `str' to the server."""
+ """Send `str` to the server.
+
+ ``str`` can be a string object, a file-like object that supports
+ a .read() method, or an iterable object that supports a .next()
+ method.
+ """
if self.sock is None:
if self.auto_open:
self.connect()
@@ -710,6 +715,10 @@
while data:
self.sock.sendall(data)
data=str.read(blocksize)
+ elif hasattr(str,'next'):
+ if self.debuglevel > 0: print "sendIng an iterable"
+ for data in str:
+ self.sock.sendall(data)
else:
self.sock.sendall(str)
except socket.error, v:
|
|
msg77037 - (view) |
Author: Chris AtLee (catlee) |
Date: 2008-12-05 16:43 |
|
The attached patch implements this for python 2.7. It also adds support
for iterable bodies in urllib2, where it is more generally useful.
urllib2 enforces the presence of a Content-Length header in the request
if the body is an iterable, whereas httplib does not.
The patch also includes updates to docs and tests (which all pass as of
r67584 on my macbook)
|
|
msg84304 - (view) |
Author: Jeremy Hylton (jhylton) |
Date: 2009-03-28 12:21 |
|
Seems like a reasonable feature request. I'm going to apply a variant
of the patch in 3.1 first.
|
|
| Date |
User |
Action |
Args |
| 2009-05-16 20:34:20 | ajaksu2 | set | priority: normal stage: test needed versions:
+ Python 3.2 |
| 2009-03-28 12:21:08 | jhylton | set | nosy:
+ jhylton messages:
+ msg84304
assignee: jhylton resolution: accepted |
| 2009-02-12 17:47:25 | ajaksu2 | link | issue3244 dependencies |
| 2008-12-05 16:43:44 | catlee | set | files:
+ python-3243.patch keywords:
+ patch messages:
+ msg77037 |
| 2008-06-30 18:01:18 | catlee | create | |
|