255
255
self.assertEqual('realm="Thou should not pass"', remainder)
258
class TestHTTPRangeParsing(tests.TestCase):
261
super(TestHTTPRangeParsing, self).setUp()
262
# We focus on range parsing here and ignore everything else
263
class RequestHandler(http_server.TestingHTTPRequestHandler):
264
def setup(self): pass
265
def handle(self): pass
266
def finish(self): pass
268
self.req_handler = RequestHandler(None, None, None)
270
def assertRanges(self, ranges, header, file_size):
271
self.assertEquals(ranges,
272
self.req_handler._parse_ranges(header, file_size))
274
def test_simple_range(self):
275
self.assertRanges([(0,2)], 'bytes=0-2', 12)
278
self.assertRanges([(8, 11)], 'bytes=-4', 12)
280
def test_tail_bigger_than_file(self):
281
self.assertRanges([(0, 11)], 'bytes=-99', 12)
283
def test_range_without_end(self):
284
self.assertRanges([(4, 11)], 'bytes=4-', 12)
286
def test_invalid_ranges(self):
287
self.assertRanges(None, 'bytes=12-22', 12)
288
self.assertRanges(None, 'bytes=1-3,12-22', 12)
289
self.assertRanges(None, 'bytes=-', 12)
258
292
class TestHTTPServer(tests.TestCase):
259
293
"""Test the HTTP servers implementations."""
428
462
"""Test the http connections."""
430
464
scenarios = multiply_scenarios(
431
vary_by_http_client_implementation(),
465
vary_by_http_client_implementation(),
432
466
vary_by_http_protocol_version(),
493
527
class TestPost(tests.TestCase):
495
529
scenarios = multiply_scenarios(
496
vary_by_http_client_implementation(),
530
vary_by_http_client_implementation(),
497
531
vary_by_http_protocol_version(),
554
588
scenarios = multiply_scenarios(
555
vary_by_http_client_implementation(),
589
vary_by_http_client_implementation(),
556
590
vary_by_http_protocol_version(),
1030
1064
"""Tests readv requests against a server erroring out on too much ranges."""
1032
1066
scenarios = multiply_scenarios(
1033
vary_by_http_client_implementation(),
1067
vary_by_http_client_implementation(),
1034
1068
vary_by_http_protocol_version(),
1077
1111
def _proxied_request(self):
1078
1112
handler = _urllib2_wrappers.ProxyHandler()
1079
request = _urllib2_wrappers.Request('GET','http://baz/buzzle')
1113
request = _urllib2_wrappers.Request('GET', 'http://baz/buzzle')
1080
1114
handler.set_proxy(request, 'http')
1090
1124
request = self._proxied_request()
1091
1125
self.assertFalse(request.headers.has_key('Proxy-authorization'))
1127
def test_user_with_at(self):
1128
self.overrideEnv('http_proxy',
1129
'http://username@domain:password@proxy_host:1234')
1130
request = self._proxied_request()
1131
self.assertFalse(request.headers.has_key('Proxy-authorization'))
1093
1133
def test_invalid_proxy(self):
1094
1134
"""A proxy env variable without scheme"""
1095
1135
self.overrideEnv('http_proxy', 'host:1234')
1128
1168
scenarios = multiply_scenarios(
1129
vary_by_http_client_implementation(),
1169
vary_by_http_client_implementation(),
1130
1170
vary_by_http_protocol_version(),
1223
1263
"""Test the Range header in GET methods."""
1225
1265
scenarios = multiply_scenarios(
1226
vary_by_http_client_implementation(),
1266
vary_by_http_client_implementation(),
1227
1267
vary_by_http_protocol_version(),
1273
1313
"""Test redirection between http servers."""
1275
1315
scenarios = multiply_scenarios(
1276
vary_by_http_client_implementation(),
1316
vary_by_http_client_implementation(),
1277
1317
vary_by_http_protocol_version(),
1348
1388
scenarios = multiply_scenarios(
1349
vary_by_http_client_implementation(),
1389
vary_by_http_client_implementation(),
1350
1390
vary_by_http_protocol_version(),
1401
1441
"""Test transport.do_catching_redirections."""
1403
1443
scenarios = multiply_scenarios(
1404
vary_by_http_client_implementation(),
1444
vary_by_http_client_implementation(),
1405
1445
vary_by_http_protocol_version(),
1756
1796
class SmartHTTPTunnellingTest(tests.TestCaseWithTransport):
1758
1798
scenarios = multiply_scenarios(
1759
vary_by_http_client_implementation(),
1799
vary_by_http_client_implementation(),
1760
1800
vary_by_http_protocol_version(),