Rev 2496: Fix PyCurl single-range bug (Vincent Ladeuil, #112719) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat May 26 17:00:37 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2496
revision-id: pqm at pqm.ubuntu.com-20070526160035-utugnd3he5zvo60s
parent: pqm at pqm.ubuntu.com-20070525050023-ip6kst9coq8a32z5
parent: aaron.bentley at utoronto.ca-20070526153055-gdl80ttx0j7wwwmu
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2007-05-26 17:00:35 +0100
message:
  Fix PyCurl single-range bug (Vincent Ladeuil, #112719)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/HTTPTestUtil.py   HTTPTestUtil.py-20050914180604-247d3aafb7a43343
  bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
  bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
  bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
    ------------------------------------------------------------
    revno: 2495.1.1
    merged: aaron.bentley at utoronto.ca-20070526153055-gdl80ttx0j7wwwmu
    parent: pqm at pqm.ubuntu.com-20070525050023-ip6kst9coq8a32z5
    parent: v.ladeuil+lp at free.fr-20070506065957-4jdlek9i5at2qb36
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: bzr.ab.integration
    timestamp: Sat 2007-05-26 11:30:55 -0400
    message:
      Merge PyCurl single-range bug
    ------------------------------------------------------------
    revno: 2481.3.1
    merged: v.ladeuil+lp at free.fr-20070506065957-4jdlek9i5at2qb36
    parent: pqm at pqm.ubuntu.com-20070504034556-wzcw478l7qkppkq0
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 112719
    timestamp: Sun 2007-05-06 08:59:57 +0200
    message:
      Fix bug #112719 by using the right range header.
      
      * HTTPTestUtil.py:
      (SingleOnlyRangeRequestHandler): Noisily refuses mutliple range
      requests.
      
      * test_http.py:
      (TestSingleOnlyRangeRequestServer): Test the retry mechanism when
      a server refuses to handle a mutiple range request without
      silently replying with a single range or full file response.
      
      * _pycurl.py:
      (PyCurlTransport._get_ranged): The header have been built taken
      into account the range hint, don't rebuilt it *ignoring* that
      hint.
=== modified file 'NEWS'
--- a/NEWS	2007-05-25 04:00:47 +0000
+++ b/NEWS	2007-05-26 15:30:55 +0000
@@ -28,6 +28,9 @@
     * Let TestUIFactoy encode the password prompt with its own stdout.
       (Vincent Ladeuil, #110204)
 
+    * pycurl should take use the range header that takes the range hint
+      into account.
+      (Vincent Ladeuil, #112719)
 
 bzr 0.16  2007-05-07
   

=== modified file 'bzrlib/tests/HTTPTestUtil.py'
--- a/bzrlib/tests/HTTPTestUtil.py	2007-04-24 10:05:23 +0000
+++ b/bzrlib/tests/HTTPTestUtil.py	2007-05-06 06:59:57 +0000
@@ -162,6 +162,19 @@
         return self.get_single_range(file, file_size, start, end)
 
 
+class SingleOnlyRangeRequestHandler(TestingHTTPRequestHandler):
+    """Only reply to simple range requests, errors out on multiple"""
+
+    def get_multiple_ranges(self, file, file_size, ranges):
+        """Refuses the multiple ranges request"""
+        if len(ranges) > 1:
+            file.close()
+            self.send_error(416, "Requested range not satisfiable")
+            return
+        (start, end) = ranges[0]
+        return self.get_single_range(file, file_size, start, end)
+
+
 class NoRangeRequestHandler(TestingHTTPRequestHandler):
     """Ignore range requests without notice"""
 

=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2007-04-26 07:21:24 +0000
+++ b/bzrlib/tests/test_http.py	2007-05-06 06:59:57 +0000
@@ -58,6 +58,7 @@
     ProxyDigestAuthServer,
     ProxyServer,
     SingleRangeRequestHandler,
+    SingleOnlyRangeRequestHandler,
     TestCaseWithRedirectedWebserver,
     TestCaseWithTwoWebservers,
     TestCaseWithWebserver,
@@ -693,6 +694,26 @@
     """Tests single range requests accepting server for pycurl implementation"""
 
 
+class TestSingleOnlyRangeRequestServer(TestRangeRequestServer):
+    """Test readv against a server which only accept single range requests"""
+
+    def create_transport_readonly_server(self):
+        return HttpServer(SingleOnlyRangeRequestHandler)
+
+
+class TestSingleOnlyRangeRequestServer_urllib(TestSingleOnlyRangeRequestServer,
+                                              TestCaseWithWebserver):
+    """Tests single range requests accepting server for urllib implementation"""
+
+    _transport = HttpTransport_urllib
+
+
+class TestSingleOnlyRangeRequestServer_pycurl(TestWithTransport_pycurl,
+                                              TestSingleOnlyRangeRequestServer,
+                                              TestCaseWithWebserver):
+    """Tests single range requests accepting server for pycurl implementation"""
+
+
 class TestNoRangeRequestServer(TestRangeRequestServer):
     """Test readv against a server which do not accept range requests"""
 

=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py	2007-04-26 08:15:40 +0000
+++ b/bzrlib/transport/http/__init__.py	2007-05-06 06:59:57 +0000
@@ -255,7 +255,7 @@
 
         try_again = False
         # The server does not gives us enough data or
-        # bogus-looking result, let's try again with
+        # a bogus-looking result, let's try again with
         # a simpler request if possible.
         if self._range_hint == 'multi':
             self._range_hint = 'single'

=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py	2007-03-13 17:00:20 +0000
+++ b/bzrlib/transport/http/_pycurl.py	2007-05-06 06:59:57 +0000
@@ -199,9 +199,7 @@
             # Forget ranges, the server can't handle them
             return self._get_full(relpath)
 
-        self._curl_perform(curl, header,
-                           ['Range: bytes=%s'
-                            % self.range_header(ranges, tail_amount)])
+        self._curl_perform(curl, header, ['Range: bytes=%s' % range_header])
         data.seek(0)
 
         code = curl.getinfo(pycurl.HTTP_CODE)




More information about the bazaar-commits mailing list