147
147
def test_content_type_re(self):
148
148
self.regex = response.HttpMultipartRangeResponse._CONTENT_TYPE_RE
149
self.assertRegexMatches(('xxyyzz',),
149
self.assertRegexMatches(('', 'xxyyzz'),
150
150
'multipart/byteranges; boundary = xxyyzz')
151
self.assertRegexMatches(('xxyyzz',),
151
self.assertRegexMatches(('', 'xxyyzz'),
152
152
'multipart/byteranges;boundary=xxyyzz')
153
self.assertRegexMatches(('xx yy zz',),
153
self.assertRegexMatches(('', 'xx yy zz'),
154
154
' multipart/byteranges ; boundary= xx yy zz ')
155
self.assertRegexMatches(('"', 'xx yy zz'),
156
' multipart/byteranges ; boundary= "xx yy zz" ')
157
self.assertEqual(None,
159
' multipart/byteranges ; boundary= "xx yy zz '))
160
self.assertEqual(None,
162
' multipart/byteranges ; boundary= xx yy zz" '))
155
163
self.assertEqual(None,
156
164
self.regex.match('multipart byteranges;boundary=xx'))
389
397
mbp@sourcefrog.net-20050314025737-55eb441f430ab4ba
390
398
mbp@sourcefrog.net-20050314025901-d74aa93bb7ee8f62
392
--418470f848b63279b--\r\n'
400
--418470f848b63279b--\r
403
_multipart_squid_range_response = (206, """HTTP/1.0 206 Partial Content\r
404
Date: Thu, 31 Aug 2006 21:16:22 GMT\r
405
Server: Apache/2.2.2 (Unix) DAV/2\r
406
Last-Modified: Thu, 31 Aug 2006 17:57:06 GMT\r
407
Accept-Ranges: bytes\r
408
Content-Type: multipart/byteranges; boundary="squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196"\r
409
Content-Length: 598\r
410
X-Cache: MISS from localhost.localdomain\r
411
X-Cache-Lookup: HIT from localhost.localdomain:3128\r
412
Proxy-Connection: keep-alive\r
416
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
417
Content-Type: text/plain\r
418
Content-Range: bytes 0-99/18672\r
422
scott@netsplit.com-20050708230047-47c7868f276b939f fulltext 0 863 :
424
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
425
Content-Type: text/plain\r
426
Content-Range: bytes 300-499/18672\r
428
com-20050708231537-2b124b835395399a :
429
scott@netsplit.com-20050820234126-551311dbb7435b51 line-delta 1803 479 .scott@netsplit.com-20050820232911-dc4322a084eadf7e :
430
scott@netsplit.com-20050821213706-c86\r
431
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196--\r
476
515
self.check_header('Content-Type',
477
516
'multipart/byteranges; boundary=418470f848b63279b')
518
def test_multi_squid_range(self):
519
self.use_response(_multipart_squid_range_response)
521
self.check_header('Content-Length', '598')
522
self.check_header('Content-Type',
523
'multipart/byteranges; '\
524
'boundary="squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196"')
479
526
def test_redirect(self):
480
527
"""We default to returning the last group of headers in the file."""
481
528
self.use_response(_redirect_response)
611
def test_multi_squid_range(self):
612
out = self.get_response(_multipart_squid_range_response)
613
self.assertIsInstance(out, response.HttpMultipartRangeResponse)
615
# Just make sure we can read the right contents
564
622
def test_invalid_response(self):
565
623
self.assertRaises(errors.InvalidHttpResponse,
566
624
self.get_response, _invalid_response)