summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-12-17 17:35:56 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-12-17 17:35:56 (GMT)
commit988dbd7bc2bb8a41cf91a12c8bff9a916651769f (patch)
tree897d68ce2dcd275487d04737635a7c92bee97bd6 /Lib/test
parent7cb3051dc304a0cf8da73a647b259a4dc215ea39 (diff)
downloadcpython-988dbd7bc2bb8a41cf91a12c8bff9a916651769f.zip
cpython-988dbd7bc2bb8a41cf91a12c8bff9a916651769f.tar.gz
cpython-988dbd7bc2bb8a41cf91a12c8bff9a916651769f.tar.bz2
Issue #10711: Remove HTTP 0.9 support from http.client. The `strict`
parameter to HTTPConnection and friends is deprecated.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_urllib.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index fe557ff..3003331 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -139,8 +139,10 @@ class urlopen_HttpTests(unittest.TestCase):
def fakehttp(self, fakedata):
class FakeSocket(io.BytesIO):
+ io_refs = 1
def sendall(self, str): pass
def makefile(self, *args, **kwds):
+ self.io_refs += 1
return self
def read(self, amt=None):
if self.closed: return b""
@@ -148,6 +150,10 @@ class urlopen_HttpTests(unittest.TestCase):
def readline(self, length=None):
if self.closed: return b""
return io.BytesIO.readline(self, length)
+ def close(self):
+ self.io_refs -= 1
+ if self.io_refs == 0:
+ io.BytesIO.close(self)
class FakeHTTPConnection(http.client.HTTPConnection):
def connect(self):
self.sock = FakeSocket(fakedata)
@@ -157,8 +163,8 @@ class urlopen_HttpTests(unittest.TestCase):
def unfakehttp(self):
http.client.HTTPConnection = self._connection_class
- def test_read(self):
- self.fakehttp(b"Hello!")
+ def check_read(self, ver):
+ self.fakehttp(b"HTTP/" + ver + b" 200 OK\r\n\r\nHello!")
try:
fp = urlopen("http://python.org/")
self.assertEqual(fp.readline(), b"Hello!")
@@ -168,6 +174,17 @@ class urlopen_HttpTests(unittest.TestCase):
finally:
self.unfakehttp()
+ def test_read_0_9(self):
+ # "0.9" response accepted (but not "simple responses" without
+ # a status line)
+ self.check_read(b"0.9")
+
+ def test_read_1_0(self):
+ self.check_read(b"1.0")
+
+ def test_read_1_1(self):
+ self.check_read(b"1.1")
+
def test_read_bogus(self):
# urlopen() should raise IOError for many error codes.
self.fakehttp(b'''HTTP/1.1 401 Authentication Required
@@ -191,7 +208,7 @@ Content-Type: text/html; charset=iso-8859-1
self.unfakehttp()
def test_userpass_inurl(self):
- self.fakehttp(b"Hello!")
+ self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
try:
fp = urlopen("http://user:pass@python.org/")
self.assertEqual(fp.readline(), b"Hello!")