Skip to content

Commit caf9269

Browse files
committed
fix aiohttp crashing on gzipped HEAD responses
* This is a hack. aiohttp tries to unzip the content body for HEAD responses when the Content-Encoding header is present. Since HEAD responses don't have bodies, this crashes with a content encoding error. This bug has been fix in aiohttp v0.22, but we are not yet ready to upgrade that.
1 parent e3b6c55 commit caf9269

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mfr/providers/osf/provider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import furl
99
import aiohttp
10+
from aiohttp.errors import ContentEncodingError
1011

1112
from waterbutler.core import streams
1213

@@ -69,11 +70,14 @@ async def metadata(self):
6970
# To make changes to current code as minimal as possible
7071
try:
7172
metadata = {'data': json.loads(metadata_request.headers['x-waterbutler-metadata'])['attributes']}
73+
await metadata_request.release()
7274
except KeyError:
7375
raise exceptions.MetadataError(
7476
'Failed to fetch metadata. Received response code {}'.format(str(metadata_request.status)),
7577
code=400)
76-
await metadata_request.release()
78+
except ContentEncodingError:
79+
pass # hack: aiohttp tries to unzip empty body when Content-Encoding is set
80+
7781
self.metrics.add('metadata.raw', metadata)
7882

7983
# e.g.,

0 commit comments

Comments
 (0)