Skip to content

Commit

Permalink
Fixed cookies= httpx warning, refs #2307
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Mar 15, 2024
1 parent 5af6837 commit 54f5604
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,50 +1935,58 @@ def _fix(self, path, avoid_path_rewrites=False):

async def get(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.get(self._fix(path), **kwargs)

async def options(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.options(self._fix(path), **kwargs)

async def head(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.head(self._fix(path), **kwargs)

async def post(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.post(self._fix(path), **kwargs)

async def put(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.put(self._fix(path), **kwargs)

async def patch(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.patch(self._fix(path), **kwargs)

async def delete(self, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.delete(self._fix(path), **kwargs)

async def request(self, method, path, **kwargs):
avoid_path_rewrites = kwargs.pop("avoid_path_rewrites", None)
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app)
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await client.request(
method, self._fix(path, avoid_path_rewrites), **kwargs
Expand Down

0 comments on commit 54f5604

Please sign in to comment.