python-httpfile 0.0.5.1__tar.gz → 0.0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/PKG-INFO +1 -1
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/httpfile/__init__.py +10 -22
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/pyproject.toml +1 -1
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/LICENSE +0 -0
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/httpfile/py.typed +0 -0
- {python_httpfile-0.0.5.1 → python_httpfile-0.0.5.2}/readme.md +0 -0
|
@@ -1068,33 +1068,17 @@ if find_spec("aiohttp"):
|
|
|
1068
1068
|
global _aiohttp_urlopen
|
|
1069
1069
|
from aiohttp import request, ClientSession
|
|
1070
1070
|
|
|
1071
|
-
close_session = True
|
|
1072
1071
|
if isinstance(urlopen, ClientSession):
|
|
1073
1072
|
urlopen = urlopen.get
|
|
1074
|
-
|
|
1075
|
-
if urlopen is None:
|
|
1073
|
+
elif urlopen is None:
|
|
1076
1074
|
if _aiohttp_urlopen is None:
|
|
1077
1075
|
urlopen = _aiohttp_urlopen = partial(request, "GET")
|
|
1078
1076
|
else:
|
|
1079
1077
|
urlopen = _aiohttp_urlopen
|
|
1080
|
-
else:
|
|
1081
|
-
func = urlopen
|
|
1082
|
-
if isinstance(func, partial):
|
|
1083
|
-
func = func.func
|
|
1084
|
-
close_session = not (
|
|
1085
|
-
isinstance(func, MethodType) and
|
|
1086
|
-
isinstance(func.__self__, ClientSession)
|
|
1087
|
-
)
|
|
1088
1078
|
async def urlopen_wrapper(url: str, headers: None | Mapping = headers):
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
try:
|
|
1093
|
-
await resp._session.close()
|
|
1094
|
-
except AttributeError:
|
|
1095
|
-
pass
|
|
1096
|
-
resp.close()
|
|
1097
|
-
resp.aclose = aclose
|
|
1079
|
+
ctx = urlopen(url, headers=headers)
|
|
1080
|
+
resp = await ctx.__aenter__()
|
|
1081
|
+
resp.aclose = lambda: ctx.__aexit__(None, None, None)
|
|
1098
1082
|
resp.raise_for_status()
|
|
1099
1083
|
return resp
|
|
1100
1084
|
await super().__ainit__(
|
|
@@ -1133,7 +1117,7 @@ if find_spec("httpx"):
|
|
|
1133
1117
|
if "__del__" not in Client.__dict__:
|
|
1134
1118
|
setattr(Client, "__del__", lambda self: self.close())
|
|
1135
1119
|
session = Client()
|
|
1136
|
-
|
|
1120
|
+
resp = session.send(
|
|
1137
1121
|
request=session.build_request(
|
|
1138
1122
|
method=method,
|
|
1139
1123
|
url=url,
|
|
@@ -1143,6 +1127,8 @@ if find_spec("httpx"):
|
|
|
1143
1127
|
follow_redirects=follow_redirects,
|
|
1144
1128
|
stream=stream,
|
|
1145
1129
|
)
|
|
1130
|
+
setattr(resp, "session", session)
|
|
1131
|
+
return resp
|
|
1146
1132
|
|
|
1147
1133
|
async def httpx_request_async(
|
|
1148
1134
|
url,
|
|
@@ -1158,7 +1144,7 @@ if find_spec("httpx"):
|
|
|
1158
1144
|
if "__del__" not in AsyncClient.__dict__:
|
|
1159
1145
|
setattr(AsyncClient, "__del__", lambda self: run_async(self.aclose()))
|
|
1160
1146
|
session = AsyncClient()
|
|
1161
|
-
|
|
1147
|
+
resp = await session.send(
|
|
1162
1148
|
request=session.build_request(
|
|
1163
1149
|
method=method,
|
|
1164
1150
|
url=url,
|
|
@@ -1168,6 +1154,8 @@ if find_spec("httpx"):
|
|
|
1168
1154
|
follow_redirects=follow_redirects,
|
|
1169
1155
|
stream=stream,
|
|
1170
1156
|
)
|
|
1157
|
+
setattr(resp, "session", session)
|
|
1158
|
+
return resp
|
|
1171
1159
|
|
|
1172
1160
|
class HttpxFileReader(HTTPFileReader):
|
|
1173
1161
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|