summaryrefslogtreecommitdiff
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-11-12 10:32:47 +0000
committerMartin v. Löwis <martin@v.loewis.de>2006-11-12 10:32:47 +0000
commit040a927cd14e799454b246dd1f56fd7f4fdff03a (patch)
tree1d7e405492eecb89f90faf3751ee0368a81f2a56 /Lib/test/test_httplib.py
parent1ee79f16e859fd0a6ea3af64a539b5198b8ab7a3 (diff)
downloadcpython-git-040a927cd14e799454b246dd1f56fd7f4fdff03a.tar.gz
Patch #1065257: Support passing open files as body in
HTTPConnection.request().
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 8d9a706833..90a4e55009 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -10,9 +10,10 @@ class FakeSocket:
def __init__(self, text, fileclass=StringIO.StringIO):
self.text = text
self.fileclass = fileclass
+ self.data = ''
def sendall(self, data):
- self.data = data
+ self.data += data
def makefile(self, mode, bufsize=None):
if mode != 'r' and mode != 'rb':
@@ -133,6 +134,16 @@ class BasicTest(TestCase):
self.fail("Did not expect response from HEAD request")
resp.close()
+ def test_send_file(self):
+ expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
+ 'Accept-Encoding: identity\r\nContent-Length:'
+
+ body = open(__file__, 'rb')
+ conn = httplib.HTTPConnection('example.com')
+ sock = FakeSocket(body)
+ conn.sock = sock
+ conn.request('GET', '/foo', body)
+ self.assertTrue(sock.data.startswith(expected))
class OfflineTest(TestCase):
def test_responses(self):