def _verify_content_length(self):
     # See: https://github.com/kennethreitz/requests/issues/1855
     # Basically, our http library doesn't do this for us, so we have
     # to do this ourself.
     if self._content_length is not None and \
             self._amount_read != int(self._content_length):
         raise IncompleteReadError(actual_bytes=self._amount_read,
                                   expected_bytes=int(self._content_length))
Exemple #2
0
def _validate_content_length(expected_content_length, body_length):
    # See: https://github.com/kennethreitz/requests/issues/1855
    # Basically, our http library doesn't do this for us, so we have
    # to do this ourself.
    if expected_content_length is not None:
        if int(expected_content_length) != body_length:
            raise IncompleteReadError(
                actual_bytes=body_length,
                expected_bytes=int(expected_content_length))
 def test_incomplete_read_is_retried(self):
     self.client.get_object.side_effect = \
             IncompleteReadError(actual_bytes=1, expected_bytes=2)
     task = DownloadPartTask(0, 1024 * 1024, self.result_queue,
                             self.filename, self.context, self.io_queue)
     with self.assertRaises(RetriesExeededError):
         task()
     self.context.cancel.assert_called_with()
     self.assertEqual(DownloadPartTask.TOTAL_ATTEMPTS,
                      self.client.get_object.call_count)
Exemple #4
0
 def _verify_content_length(self):
     if self._content_length is not None and \
             self._amount_read != int(self._content_length):
         raise IncompleteReadError(actual_bytes=self._amount_read,
                                   expected_bytes=int(self._content_length))