Fix HTTPAction close logic

This commit is contained in:
Roland Thomas Jr 2025-05-08 00:51:34 -04:00
parent 880d86d47d
commit 26aab7f2d5
Signed by: roland
GPG Key ID: 7C3C2B085A4C2872
1 changed files with 19 additions and 19 deletions

View File

@ -105,28 +105,28 @@ class HTTPAction(Action):
session = aiohttp.ClientSession() session = aiohttp.ClientSession()
context.set("http_session", session) context.set("http_session", session)
context.set("_session_should_close", True) context.set("_session_should_close", True)
else: else:
session = aiohttp.ClientSession() session = aiohttp.ClientSession()
async with session.request( try:
self.method, async with session.request(
self.url, self.method,
headers=self.headers, self.url,
params=self.params, headers=self.headers,
json=self.json, params=self.params,
data=self.data, json=self.json,
) as response: data=self.data,
body = await response.text() ) as response:
return { body = await response.text()
"status": response.status, return {
"url": str(response.url), "status": response.status,
"headers": dict(response.headers), "url": str(response.url),
"body": body, "headers": dict(response.headers),
} "body": body,
}
if not self.shared_context: finally:
await session.close() if not self.shared_context:
await session.close()
async def preview(self, parent: Tree | None = None): async def preview(self, parent: Tree | None = None):
label = [ label = [