diff -r 69ea73015132 Lib/httplib.py --- a/Lib/httplib.py Wed Sep 02 22:07:31 2015 -0400 +++ b/Lib/httplib.py Thu Sep 03 15:14:26 2015 +1200 @@ -1420,12 +1420,24 @@ self._done() return s - def readline(self): + def readline(self, amt=None): if self._line_consumed: - return self._file.readline() + # We need to pass 'amt' to satisfy the LineAndFileWrapper class, + # which expects it. + return self._file.readline(amt) assert self._line_left - s = self._line[self._line_offset:] - self._done() + if amt is None or amt > self._line_left: + s = self._line[self._line_offset:] + self._done() + else: + assert amt <= self._line_left + i = self._line_offset + j = i + amt + s = self._line[i:j] + self._line_offset = j + self._line_left -= amt + if self._line_left == 0: + self._done() return s def readlines(self, size=None): diff -r 69ea73015132 Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Wed Sep 02 22:07:31 2015 -0400 +++ b/Lib/test/test_httplib.py Thu Sep 03 15:14:26 2015 +1200 @@ -48,6 +48,9 @@ def close(self): pass + def close(self): + pass + class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): @@ -578,6 +581,19 @@ #self.assertTrue(response[0].closed) self.assertTrue(conn.sock.file_closed) + def test_proxy_tunnel_without_status_line(self): + # Issue 17849: Confirm we can read from HTTP/0.9 style responses to + # CONNECT requests. + body = "X-Foo: bar\r\n\r\nhello world" + conn = httplib.HTTPConnection('example.com', strict=False) + conn.set_tunnel('foo') + conn.sock = FakeSocket(body) + try: + conn._tunnel() + except TypeError: + self.fail() + + class OfflineTest(TestCase): def test_responses(self): self.assertEqual(httplib.responses[httplib.NOT_FOUND], "Not Found") diff -r 69ea73015132 configure --- a/configure Wed Sep 02 22:07:31 2015 -0400 +++ b/configure Thu Sep 03 15:14:26 2015 +1200 @@ -6102,7 +6102,7 @@ # On Intel macs default to a deployment # target of 10.4, that's the first OSX # release with Intel support. - cur_target="10.4" + cur_target="10.9" fi fi fi