~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http_response.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-31 21:34:20 UTC
  • mto: This revision was merged to the branch mainline in revision 1981.
  • Revision ID: john@arbash-meinel.com-20060831213420-2297bb5599b11cb9
Fix bug #57723, parse boundary="" correctly, since Squid uses it

Show diffs side-by-side

added added

removed removed

Lines of Context:
389
389
mbp@sourcefrog.net-20050314025737-55eb441f430ab4ba
390
390
mbp@sourcefrog.net-20050314025901-d74aa93bb7ee8f62
391
391
mbp@source\r
392
 
--418470f848b63279b--\r\n'
 
392
--418470f848b63279b--\r
 
393
""")
 
394
 
 
395
_multipart_squid_range_response = (206, """HTTP/1.0 206 Partial Content\r
 
396
Date: Thu, 31 Aug 2006 21:16:22 GMT\r
 
397
Server: Apache/2.2.2 (Unix) DAV/2\r
 
398
Last-Modified: Thu, 31 Aug 2006 17:57:06 GMT\r
 
399
Accept-Ranges: bytes\r
 
400
Content-Type: multipart/byteranges; boundary="squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196"\r
 
401
Content-Length: 598\r
 
402
X-Cache: MISS from localhost.localdomain\r
 
403
X-Cache-Lookup: HIT from localhost.localdomain:3128\r
 
404
Proxy-Connection: keep-alive\r
 
405
\r
 
406
""",
 
407
"""\r
 
408
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
 
409
Content-Type: text/plain\r
 
410
Content-Range: bytes 0-99/18672\r
 
411
\r
 
412
# bzr knit index 8
 
413
 
 
414
scott@netsplit.com-20050708230047-47c7868f276b939f fulltext 0 863  :
 
415
scott@netsp\r
 
416
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196\r
 
417
Content-Type: text/plain\r
 
418
Content-Range: bytes 300-499/18672\r
 
419
\r
 
420
com-20050708231537-2b124b835395399a :
 
421
scott@netsplit.com-20050820234126-551311dbb7435b51 line-delta 1803 479 .scott@netsplit.com-20050820232911-dc4322a084eadf7e :
 
422
scott@netsplit.com-20050821213706-c86\r
 
423
--squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196--\r
393
424
""")
394
425
 
395
426
 
476
507
        self.check_header('Content-Type',
477
508
                          'multipart/byteranges; boundary=418470f848b63279b')
478
509
 
 
510
    def test_multi_squid_range(self):
 
511
        self.use_response(_multipart_squid_range_response)
 
512
 
 
513
        self.check_header('Content-Length', '598')
 
514
        self.check_header('Content-Type',
 
515
                          'multipart/byteranges; '\
 
516
                          'boundary="squid/2.5.STABLE12:C99323425AD4FE26F726261FA6C24196"')
 
517
 
479
518
    def test_redirect(self):
480
519
        """We default to returning the last group of headers in the file."""
481
520
        self.use_response(_redirect_response)
561
600
        out.seek(1000)
562
601
        out.read(1050)
563
602
 
 
603
    def test_multi_squid_range(self):
 
604
        out = self.get_response(_multipart_squid_range_response)
 
605
        self.assertIsInstance(out, response.HttpMultipartRangeResponse)
 
606
 
 
607
        # Just make sure we can read the right contents
 
608
        out.seek(0)
 
609
        out.read(100)
 
610
 
 
611
        out.seek(300)
 
612
        out.read(200)
 
613
 
564
614
    def test_invalid_response(self):
565
615
        self.assertRaises(errors.InvalidHttpResponse,
566
616
            self.get_response, _invalid_response)