Skip to content

Commit

Permalink
fix aiohttp crashing on gzipped HEAD responses
Browse files Browse the repository at this point in the history
 * 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.
  • Loading branch information
felliott committed Sep 22, 2016
1 parent e3b6c55 commit caf9269
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mfr/providers/osf/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import furl
import aiohttp
from aiohttp.errors import ContentEncodingError

from waterbutler.core import streams

Expand Down Expand Up @@ -69,11 +70,14 @@ async def metadata(self):
# To make changes to current code as minimal as possible
try:
metadata = {'data': json.loads(metadata_request.headers['x-waterbutler-metadata'])['attributes']}
await metadata_request.release()
except KeyError:
raise exceptions.MetadataError(
'Failed to fetch metadata. Received response code {}'.format(str(metadata_request.status)),
code=400)
await metadata_request.release()
except ContentEncodingError:
pass # hack: aiohttp tries to unzip empty body when Content-Encoding is set

self.metrics.add('metadata.raw', metadata)

# e.g.,
Expand Down

0 comments on commit caf9269

Please sign in to comment.