Rev 2482: Fix bug #112719 by using the right range header. in file:///v/home/vila/src/bugs/112719/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun May 6 08:00:00 BST 2007


At file:///v/home/vila/src/bugs/112719/

------------------------------------------------------------
revno: 2482
revision-id: 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:
  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
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2007-05-01 22:41:41 +0000
+++ b/NEWS	2007-05-06 06:59:57 +0000
@@ -18,6 +18,10 @@
       that we can pass in the Transport that we already have.
       (John Arbash Meinel, #75721)
 
+    * pycurl should take use the range header that takes the range hint
+      into account.
+      (Vincent Ladeuil, #112719)
+
 bzr 0.16rc2  2007-04-30
 
   BUGFIXES:

=== 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