python-http_request 0.1.6__py3-none-any.whl → 0.1.6.2__py3-none-any.whl

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.
http_request/__init__.py CHANGED
@@ -537,3 +537,5 @@ def normalize_request_args(
537
537
  "headers": headers_
538
538
  }
539
539
 
540
+ # TODO: 尽量要得到 content-length
541
+ # TODO: 支持对请求体进行压缩,增加一个参数用来处理(而不是判断 content-encoding,除非不是迭代器)
@@ -29,6 +29,7 @@ from filewrap import bio_chunk_iter, bio_chunk_async_iter, SupportsRead
29
29
  from http_response import (
30
30
  get_status_code, headers_get, decompress_response, parse_response,
31
31
  )
32
+ from socket_keepalive import socket_keepalive
32
33
  from yarl import URL
33
34
 
34
35
  from .. import normalize_request_args, SupportsGeturl
@@ -147,8 +148,10 @@ def urlopen(
147
148
  method: str = "GET",
148
149
  data=None,
149
150
  headers=None,
150
- **request_args,
151
+ **request_kwargs,
151
152
  ) -> HTTPResponse:
153
+ if headers is None:
154
+ headers = {}
152
155
  urlp = urlsplit(url)
153
156
  if urlp.scheme == "https":
154
157
  con: HTTPConnection = HTTPSConnection(urlp.netloc)
@@ -160,6 +163,7 @@ def urlopen(
160
163
  data,
161
164
  headers,
162
165
  )
166
+ socket_keepalive(con.sock)
163
167
  return con.getresponse()
164
168
 
165
169
 
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-http_request
3
+ Version: 0.1.6.2
4
+ Summary: Python http request utils.
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: http,request
8
+ Author: ChenyangGao
9
+ Author-email: wosiwujm@gmail.com
10
+ Requires-Python: >=3.12,<4.0
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Topic :: Software Development
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Dist: http_response (>=0.0.9)
25
+ Requires-Dist: orjson
26
+ Requires-Dist: python-argtools (>=0.0.2)
27
+ Requires-Dist: python-asynctools (>=0.1.3)
28
+ Requires-Dist: python-cookietools (>=0.1.4)
29
+ Requires-Dist: python-dicttools (>=0.0.4)
30
+ Requires-Dist: python-ensure (>=0.0.1)
31
+ Requires-Dist: python-filewrap (>=0.2.8)
32
+ Requires-Dist: python-texttools (>=0.0.5)
33
+ Requires-Dist: python-undefined (>=0.0.3)
34
+ Requires-Dist: socket_keepalive (>=0.0.1)
35
+ Requires-Dist: yarl
36
+ Project-URL: Homepage, https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
37
+ Project-URL: Repository, https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
38
+ Description-Content-Type: text/markdown
39
+
40
+ # Python http request utils.
41
+
42
+ ## Installation
43
+
44
+ You can install from [pypi](https://pypi.org/project/python-http_request/)
45
+
46
+ ```console
47
+ pip install -U python-http_request
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ```python
53
+ import http_request
54
+ import http_request.extension
55
+ ```
56
+
57
+ ## Extension
58
+
59
+ I've implemented several modules, all of which provide a ``request`` function. Their signatures are similar, so they can be used as drop-in replacements for each other.
60
+
61
+ 1. [aiohttp_client_request](https://pypi.org/project/aiohttp_client_request/)
62
+ 1. [aiosonic_request](https://pypi.org/project/aiosonic_request/)
63
+ 1. [asks_request](https://pypi.org/project/asks_request/)
64
+ 1. [blacksheep_client_request](https://pypi.org/project/blacksheep_client_request/)
65
+ 1. [curl_cffi_request](https://pypi.org/project/curl_cffi_request/)
66
+ 1. [http_client_request](https://pypi.org/project/http_client_request/)
67
+ 1. [httpcore_request](https://pypi.org/project/httpcore_request/)
68
+ 1. [httpx_request](https://pypi.org/project/httpx_request/)
69
+ 1. [hyper_request](https://pypi.org/project/hyper_request/)
70
+ 1. [pycurl_request](https://pypi.org/project/pycurl_request/)
71
+ 1. [python-urlopen](https://pypi.org/project/python-urlopen/)
72
+ 1. [requests_request](https://pypi.org/project/requests_request/)
73
+ 1. [tornado_client_request](https://pypi.org/project/tornado_client_request/)
74
+ 1. [urllib3_request](https://pypi.org/project/urllib3_request/)
75
+
76
+ To make it more general, I've encapsulated a ``request`` function
77
+
78
+ ```python
79
+ from http_request.extension import request
80
+ ```
81
+
82
+ You just need to implement a ``urlopen`` function pass to ``request``, then it can be directly extended. The ``urlopen`` function signature is roughly as follows:
83
+
84
+ ```python
85
+ def urlopen[Response](
86
+ url: str,
87
+ method: str,
88
+ data=None,
89
+ headers: None | dict[str, str] = None,
90
+ **request_args,
91
+ ) -> Response:
92
+ ...
93
+ ```
94
+
@@ -0,0 +1,8 @@
1
+ http_request/__init__.py,sha256=2zQIjE6oOksjAoo4QVgQlUeZBSTl33qb1UQZHAE9sbs,18916
2
+ http_request/extension/__init__.py,sha256=3dvnzgkk04xtCSbdThHZxZH05H1BOuE3bzdFwADdY2U,63
3
+ http_request/extension/request.py,sha256=EZaLG6N8lyF-SUU-ifszW-bZOX8i1HsirUYHFLee3Fs,26445
4
+ http_request/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ python_http_request-0.1.6.2.dist-info/METADATA,sha256=PiTzSA_tqPgAcLbPzMqDRL-HUhGAVo0ZH6VNTP14f4E,3450
6
+ python_http_request-0.1.6.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
7
+ python_http_request-0.1.6.2.dist-info/licenses/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
8
+ python_http_request-0.1.6.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 ChenyangGao <https://github.com/ChenyangGao>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,53 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: python-http_request
3
- Version: 0.1.6
4
- Summary: Python http request utils.
5
- Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
6
- License: MIT
7
- Keywords: http,request
8
- Author: ChenyangGao
9
- Author-email: wosiwujm@gmail.com
10
- Requires-Python: >=3.12,<4.0
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Topic :: Software Development
21
- Classifier: Topic :: Software Development :: Libraries
22
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
- Requires-Dist: http_response (>=0.0.9)
24
- Requires-Dist: orjson
25
- Requires-Dist: python-argtools (>=0.0.2)
26
- Requires-Dist: python-asynctools (>=0.1.3)
27
- Requires-Dist: python-cookietools (>=0.1.4)
28
- Requires-Dist: python-dicttools (>=0.0.4)
29
- Requires-Dist: python-ensure (>=0.0.1)
30
- Requires-Dist: python-filewrap (>=0.2.8)
31
- Requires-Dist: python-texttools (>=0.0.5)
32
- Requires-Dist: python-undefined (>=0.0.3)
33
- Requires-Dist: yarl
34
- Project-URL: Repository, https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
35
- Description-Content-Type: text/markdown
36
-
37
- # Python http request utils.
38
-
39
- ## Installation
40
-
41
- You can install from [pypi](https://pypi.org/project/python-http_request/)
42
-
43
- ```console
44
- pip install -U python-http_request
45
- ```
46
-
47
- ## Usage
48
-
49
- ```python
50
- import http_request
51
- import http_request.extension
52
- ```
53
-
@@ -1,9 +0,0 @@
1
- LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
- http_request/__init__.py,sha256=mWKUuVYj08ugYlzjzlKW0f-fUjMkKzz91GwHZ4usjYA,18743
3
- http_request/extension/__init__.py,sha256=3dvnzgkk04xtCSbdThHZxZH05H1BOuE3bzdFwADdY2U,63
4
- http_request/extension/request.py,sha256=W6USeI6G2jxEDwmDE1w0Mm73xfmF1WSDpVh1PPa-h9E,26321
5
- http_request/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- python_http_request-0.1.6.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
7
- python_http_request-0.1.6.dist-info/METADATA,sha256=m3wZpwodKHF1IoDzUeAt557xWPlMxCst1A0O9os6P3U,1727
8
- python_http_request-0.1.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
9
- python_http_request-0.1.6.dist-info/RECORD,,