Fix HTTPAction close logic
This commit is contained in:
parent
880d86d47d
commit
26aab7f2d5
|
@ -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 = [
|
||||||
|
|
Loading…
Reference in New Issue