Mercurial > hg
comparison mercurial/httpclient/tests/test_ssl.py @ 14376:a75e0f4ba0ab
httpclient: import revision fc731618702a of py-nonblocking-http
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 17 May 2011 10:28:03 -0500 |
parents | 5c3de67e7402 |
children | 24dbef11f477 |
comparison
equal
deleted
inserted
replaced
14375:436e5379d7ba | 14376:a75e0f4ba0ab |
---|---|
39 def testSslRereadRequired(self): | 39 def testSslRereadRequired(self): |
40 con = http.HTTPConnection('1.2.3.4:443') | 40 con = http.HTTPConnection('1.2.3.4:443') |
41 con._connect() | 41 con._connect() |
42 # extend the list instead of assign because of how | 42 # extend the list instead of assign because of how |
43 # MockSSLSocket works. | 43 # MockSSLSocket works. |
44 con.sock.data.extend(['HTTP/1.1 200 OK\r\n', | 44 con.sock.data = ['HTTP/1.1 200 OK\r\n', |
45 'Server: BogusServer 1.0\r\n', | 45 'Server: BogusServer 1.0\r\n', |
46 'MultiHeader: Value\r\n' | 46 'MultiHeader: Value\r\n' |
47 'MultiHeader: Other Value\r\n' | 47 'MultiHeader: Other Value\r\n' |
48 'MultiHeader: One More!\r\n' | 48 'MultiHeader: One More!\r\n' |
49 'Content-Length: 10\r\n', | 49 'Content-Length: 10\r\n', |
50 '\r\n' | 50 '\r\n' |
51 '1234567890' | 51 '1234567890' |
52 ]) | 52 ] |
53 con.request('GET', '/') | 53 con.request('GET', '/') |
54 | 54 |
55 expected_req = ('GET / HTTP/1.1\r\n' | 55 expected_req = ('GET / HTTP/1.1\r\n' |
56 'Host: 1.2.3.4\r\n' | 56 'Host: 1.2.3.4\r\n' |
57 'accept-encoding: identity\r\n\r\n') | 57 'accept-encoding: identity\r\n\r\n') |
66 resp.headers.getheaders('server')) | 66 resp.headers.getheaders('server')) |
67 | 67 |
68 def testSslRereadInEarlyResponse(self): | 68 def testSslRereadInEarlyResponse(self): |
69 con = http.HTTPConnection('1.2.3.4:443') | 69 con = http.HTTPConnection('1.2.3.4:443') |
70 con._connect() | 70 con._connect() |
71 # extend the list instead of assign because of how | 71 con.sock.early_data = ['HTTP/1.1 200 OK\r\n', |
72 # MockSSLSocket works. | 72 'Server: BogusServer 1.0\r\n', |
73 con.sock.early_data.extend(['HTTP/1.1 200 OK\r\n', | 73 'MultiHeader: Value\r\n' |
74 'Server: BogusServer 1.0\r\n', | 74 'MultiHeader: Other Value\r\n' |
75 'MultiHeader: Value\r\n' | 75 'MultiHeader: One More!\r\n' |
76 'MultiHeader: Other Value\r\n' | 76 'Content-Length: 10\r\n', |
77 'MultiHeader: One More!\r\n' | 77 '\r\n' |
78 'Content-Length: 10\r\n', | 78 '1234567890' |
79 '\r\n' | 79 ] |
80 '1234567890' | |
81 ]) | |
82 | 80 |
83 expected_req = self.doPost(con, False) | 81 expected_req = self.doPost(con, False) |
84 self.assertEqual(None, con.sock, | 82 self.assertEqual(None, con.sock, |
85 'Connection should have disowned socket') | 83 'Connection should have disowned socket') |
86 | 84 |
90 self.assertEqual('1234567890', resp.read()) | 88 self.assertEqual('1234567890', resp.read()) |
91 self.assertEqual(['Value', 'Other Value', 'One More!'], | 89 self.assertEqual(['Value', 'Other Value', 'One More!'], |
92 resp.headers.getheaders('multiheader')) | 90 resp.headers.getheaders('multiheader')) |
93 self.assertEqual(['BogusServer 1.0'], | 91 self.assertEqual(['BogusServer 1.0'], |
94 resp.headers.getheaders('server')) | 92 resp.headers.getheaders('server')) |
93 # no-check-code |