~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http_response.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-01 17:37:35 UTC
  • mfrom: (1979.1.2 boundary-quotes-57723)
  • Revision ID: pqm@pqm.ubuntu.com-20060901173735-543e9acad03760d1
(jam) fix bug #57723: failure when using SQUID proxy

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
 
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,
 
158
                         self.regex.match(
 
159
                             ' multipart/byteranges ; boundary= "xx yy zz '))
 
160
        self.assertEqual(None,
 
161
                         self.regex.match(
 
162
                             ' multipart/byteranges ; boundary= xx yy zz" '))
155
163
        self.assertEqual(None,
156
164
                self.regex.match('multipart byteranges;boundary=xx'))
157
165
 
389
397
mbp@sourcefrog.net-20050314025737-55eb441f430ab4ba
390
398
mbp@sourcefrog.net-20050314025901-d74aa93bb7ee8f62
391
399
mbp@source\r
392
 
--418470f848b63279b--\r\n'
 
400
--418470f848b63279b--\r
 
401
""")
 
402
 
 
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
 
413
\r
 
414
""",
 
415
"""\r
 
416
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
 
417
Content-Type: text/plain\r
 
418
Content-Range: bytes 0-99/18672\r
 
419
\r
 
420
# bzr knit index 8
 
421
 
 
422
scott@netsplit.com-20050708230047-47c7868f276b939f fulltext 0 863  :
 
423
scott@netsp\r
 
424
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
 
425
Content-Type: text/plain\r
 
426
Content-Range: bytes 300-499/18672\r
 
427
\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
393
432
""")
394
433
 
395
434
 
476
515
        self.check_header('Content-Type',
477
516
                          'multipart/byteranges; boundary=418470f848b63279b')
478
517
 
 
518
    def test_multi_squid_range(self):
 
519
        self.use_response(_multipart_squid_range_response)
 
520
 
 
521
        self.check_header('Content-Length', '598')
 
522
        self.check_header('Content-Type',
 
523
                          'multipart/byteranges; '\
 
524
                          'boundary="squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196"')
 
525
 
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)
561
608
        out.seek(1000)
562
609
        out.read(1050)
563
610
 
 
611
    def test_multi_squid_range(self):
 
612
        out = self.get_response(_multipart_squid_range_response)
 
613
        self.assertIsInstance(out, response.HttpMultipartRangeResponse)
 
614
 
 
615
        # Just make sure we can read the right contents
 
616
        out.seek(0)
 
617
        out.read(100)
 
618
 
 
619
        out.seek(300)
 
620
        out.read(200)
 
621
 
564
622
    def test_invalid_response(self):
565
623
        self.assertRaises(errors.InvalidHttpResponse,
566
624
            self.get_response, _invalid_response)