| Index: third_party/gsutil/gslib/gcs_json_media.py
|
| diff --git a/third_party/gsutil/gslib/gcs_json_media.py b/third_party/gsutil/gslib/gcs_json_media.py
|
| index 45440f9e727e4ba9bf7d1403822013982ede52e4..99684896f9d748ab0f9fda11664b23127627377c 100644
|
| --- a/third_party/gsutil/gslib/gcs_json_media.py
|
| +++ b/third_party/gsutil/gslib/gcs_json_media.py
|
| @@ -454,11 +454,8 @@ class HttpWithDownloadStream(httplib2.Http):
|
| class doc).
|
| """
|
|
|
| - def __init__(self, stream=None, *args, **kwds):
|
| - if stream is None:
|
| - raise apitools_exceptions.InvalidUserInputError(
|
| - 'Cannot create HttpWithDownloadStream with no stream')
|
| - self._stream = stream
|
| + def __init__(self, *args, **kwds):
|
| + self._stream = None
|
| self._logger = logging.getLogger()
|
| super(HttpWithDownloadStream, self).__init__(*args, **kwds)
|
|
|
| @@ -466,6 +463,10 @@ class HttpWithDownloadStream(httplib2.Http):
|
| def stream(self):
|
| return self._stream
|
|
|
| + @stream.setter
|
| + def stream(self, value):
|
| + self._stream = value
|
| +
|
| def _conn_request(self, conn, request_uri, method, body, headers): # pylint: disable=too-many-statements
|
| try:
|
| if hasattr(conn, 'sock') and conn.sock is None:
|
| @@ -513,6 +514,9 @@ class HttpWithDownloadStream(httplib2.Http):
|
| while True:
|
| new_data = http_stream.read(TRANSFER_BUFFER_SIZE)
|
| if new_data:
|
| + if self.stream is None:
|
| + raise apitools_exceptions.InvalidUserInputError(
|
| + 'Cannot exercise HttpWithDownloadStream with no stream')
|
| self.stream.write(new_data)
|
| bytes_read += len(new_data)
|
| else:
|
|
|