Skip to content

Commit

Permalink
allow redirect in HEAD request
Browse files Browse the repository at this point in the history
Newer IPFS servers seem to issue an HTTP redirect on HEAD requests to a
directory without trailing /, but aiohttp by default doesn't follow
those on a HEAD request.
  • Loading branch information
d70-t committed Jun 20, 2023
1 parent 2a73d5e commit a40d5bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipfsspec/async_ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def file_info(self, path, session):
info = {"name": path}

headers = {"Accept-Encoding": "identity"} # this ensures correct file size
res = await self.cid_head(path, session, headers=headers)
res = await self.cid_head(path, session, headers=headers, allow_redirects=True)

async with res:
self._raise_not_found_for_status(res, path)
Expand Down Expand Up @@ -105,7 +105,7 @@ async def api_post(self, endpoint, session, **kwargs):
async def _cid_req(self, method, path, headers=None, **kwargs):
headers = headers or {}
if self.resolution == "path":
res = await method(self.url + "/ipfs/" + path, trace_request_ctx={'gateway': self.url}, headers=headers)
res = await method(self.url + "/ipfs/" + path, trace_request_ctx={'gateway': self.url}, headers=headers, **kwargs)
elif self.resolution == "subdomain":
raise NotImplementedError("subdomain resolution is not yet implemented")
else:
Expand Down

0 comments on commit a40d5bc

Please sign in to comment.