python-http_request 0.1.6.1__tar.gz → 0.1.6.3__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.
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-http_request
3
- Version: 0.1.6.1
3
+ Version: 0.1.6.3
4
4
  Summary: Python http request utils.
5
- Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
6
5
  License: MIT
6
+ License-File: LICENSE
7
7
  Keywords: http,request
8
8
  Author: ChenyangGao
9
9
  Author-email: wosiwujm@gmail.com
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
19
20
  Classifier: Programming Language :: Python :: 3 :: Only
20
21
  Classifier: Topic :: Software Development
21
22
  Classifier: Topic :: Software Development :: Libraries
@@ -30,7 +31,9 @@ Requires-Dist: python-ensure (>=0.0.1)
30
31
  Requires-Dist: python-filewrap (>=0.2.8)
31
32
  Requires-Dist: python-texttools (>=0.0.5)
32
33
  Requires-Dist: python-undefined (>=0.0.3)
34
+ Requires-Dist: socket_keepalive (>=0.0.1)
33
35
  Requires-Dist: yarl
36
+ Project-URL: Homepage, https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
34
37
  Project-URL: Repository, https://github.com/ChenyangGao/python-modules/tree/main/python-http_request
35
38
  Description-Content-Type: text/markdown
36
39
 
@@ -63,6 +66,7 @@ I've implemented several modules, all of which provide a ``request`` function. T
63
66
  1. [http_client_request](https://pypi.org/project/http_client_request/)
64
67
  1. [httpcore_request](https://pypi.org/project/httpcore_request/)
65
68
  1. [httpx_request](https://pypi.org/project/httpx_request/)
69
+ 1. [hyper_request](https://pypi.org/project/hyper_request/)
66
70
  1. [pycurl_request](https://pypi.org/project/pycurl_request/)
67
71
  1. [python-urlopen](https://pypi.org/project/python-urlopen/)
68
72
  1. [requests_request](https://pypi.org/project/requests_request/)
@@ -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,7 +148,7 @@ def urlopen(
147
148
  method: str = "GET",
148
149
  data=None,
149
150
  headers=None,
150
- **request_args,
151
+ **request_kwargs,
151
152
  ) -> HTTPResponse:
152
153
  urlp = urlsplit(url)
153
154
  if urlp.scheme == "https":
@@ -158,9 +159,13 @@ def urlopen(
158
159
  method,
159
160
  urlunsplit(urlp._replace(scheme="", netloc="")),
160
161
  data,
161
- headers,
162
+ {} if headers is None else headers,
162
163
  )
163
- return con.getresponse()
164
+ socket_keepalive(con.sock)
165
+ resp = con.getresponse()
166
+ setattr(resp, "method", method.upper())
167
+ setattr(resp, "url", url)
168
+ return resp
164
169
 
165
170
 
166
171
  urlopen_async = lambda *a, **k: to_thread(urlopen, *a, **k)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-http_request"
3
- version = "0.1.6.1"
3
+ version = "0.1.6.3"
4
4
  description = "Python http request utils."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -37,6 +37,7 @@ python-ensure = ">=0.0.1"
37
37
  python-filewrap = ">=0.2.8"
38
38
  python-texttools = ">=0.0.5"
39
39
  python-undefined = ">=0.0.3"
40
+ socket_keepalive = ">=0.0.1"
40
41
  yarl = "*"
41
42
 
42
43
  [build-system]
@@ -27,6 +27,7 @@ I've implemented several modules, all of which provide a ``request`` function. T
27
27
  1. [http_client_request](https://pypi.org/project/http_client_request/)
28
28
  1. [httpcore_request](https://pypi.org/project/httpcore_request/)
29
29
  1. [httpx_request](https://pypi.org/project/httpx_request/)
30
+ 1. [hyper_request](https://pypi.org/project/hyper_request/)
30
31
  1. [pycurl_request](https://pypi.org/project/pycurl_request/)
31
32
  1. [python-urlopen](https://pypi.org/project/python-urlopen/)
32
33
  1. [requests_request](https://pypi.org/project/requests_request/)