diff --git a/waterbutler/providers/gitlab/provider.py b/waterbutler/providers/gitlab/provider.py index 28b488cd8..d72281aa5 100644 --- a/waterbutler/providers/gitlab/provider.py +++ b/waterbutler/providers/gitlab/provider.py @@ -224,6 +224,9 @@ async def download(self, path: GitLabPath, **kwargs): # type: ignore logger.debug('download-headers:: {}'.format([(x, resp.headers[x]) for x in resp.headers])) + logger.error('gitlab-size-headers: content-length:({}) ' + 'x-gitlab-size:({})'.format(resp.headers.get('Content-Length'), + resp.headers.get('X-Gitlab-Size'))) # get size from X-Gitlab-Size header, since some responses don't set Content-Length return streams.ResponseStreamReader(resp, size=int(resp.headers['X-Gitlab-Size'])) diff --git a/waterbutler/server/api/v1/provider/metadata.py b/waterbutler/server/api/v1/provider/metadata.py index a7d09d52b..66e00e192 100644 --- a/waterbutler/server/api/v1/provider/metadata.py +++ b/waterbutler/server/api/v1/provider/metadata.py @@ -5,6 +5,7 @@ import pytz from dateutil.parser import parse as datetime_parser +from tornado import httputil from waterbutler.server import utils from waterbutler.core import mime_types @@ -103,7 +104,16 @@ async def download_file(self): if ext in mime_types: self.set_header('Content-Type', mime_types[ext]) - await self.write_stream(stream) + try: + await self.write_stream(stream) + except httputil.HTTPOutputError as exc: + logger.error('Caught HTTPOutputError, checking content-length sizes') + logger.error( + '*** stream.size:({}) content-length:({})'.format( + stream.size, self._headers.get('Content-Length') + ) + ) + raise exc if getattr(stream, 'partial', False) and isinstance(stream, ResponseStreamReader): await stream.response.release()