mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
fix(http): close non-success responses safely
This commit is contained in:
+4
-4
@@ -161,7 +161,7 @@ class RequestUtils:
|
|||||||
response = self.request(method=method, url=url, **kwargs)
|
response = self.request(method=method, url=url, **kwargs)
|
||||||
yield response
|
yield response
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response is not None:
|
||||||
try:
|
try:
|
||||||
response.close()
|
response.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -280,7 +280,7 @@ class RequestUtils:
|
|||||||
try:
|
try:
|
||||||
yield response
|
yield response
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response is not None:
|
||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
def post_res(self,
|
def post_res(self,
|
||||||
@@ -654,7 +654,7 @@ class AsyncRequestUtils:
|
|||||||
response = await self.request(method=method, url=url, **kwargs)
|
response = await self.request(method=method, url=url, **kwargs)
|
||||||
yield response
|
yield response
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response is not None:
|
||||||
try:
|
try:
|
||||||
await response.aclose()
|
await response.aclose()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -785,7 +785,7 @@ class AsyncRequestUtils:
|
|||||||
try:
|
try:
|
||||||
yield response
|
yield response
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response is not None:
|
||||||
await response.aclose()
|
await response.aclose()
|
||||||
|
|
||||||
async def post_res(self,
|
async def post_res(self,
|
||||||
|
|||||||
Reference in New Issue
Block a user