python-urlopen 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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-urlopen
3
- Version: 0.1.6.1
3
+ Version: 0.1.6.3
4
4
  Summary: Python urlopen wrapper.
5
5
  Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-urlopen
6
6
  License: MIT
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Classifier: Topic :: Software Development
21
21
  Classifier: Topic :: Software Development :: Libraries
22
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
- Requires-Dist: http_client_request (>=0.0.6)
23
+ Requires-Dist: http_client_request (>=0.0.9.2)
24
24
  Requires-Dist: http_response (>=0.0.9)
25
25
  Requires-Dist: python-argtools (>=0.0.2)
26
26
  Requires-Dist: python-cookietools (>=0.1.3)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-urlopen"
3
- version = "0.1.6.1"
3
+ version = "0.1.6.3"
4
4
  description = "Python urlopen wrapper."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -27,7 +27,7 @@ include = [
27
27
 
28
28
  [tool.poetry.dependencies]
29
29
  python = "^3.12"
30
- http_client_request = ">=0.0.6"
30
+ http_client_request = ">=0.0.9.2"
31
31
  http_response = ">=0.0.9"
32
32
  python-argtools = ">=0.0.2"
33
33
  python-cookietools = ">=0.1.3"
@@ -25,7 +25,7 @@ from urllib.request import (
25
25
 
26
26
  from argtools import argcount
27
27
  from cookietools import cookies_to_str, extract_cookies, update_cookies
28
- from dicttools import iter_items
28
+ from dicttools import dict_map, iter_items
29
29
  from filewrap import bio_skip_iter, SupportsRead, SupportsWrite
30
30
  from http_client_request import ConnectionPool, HTTPResponse, CONNECTION_POOL
31
31
  from http_request import normalize_request_args, SupportsGeturl
@@ -86,38 +86,36 @@ class KeepAliveBaseHTTPHandler(AbstractHTTPHandler):
86
86
  origin = "https://" + host
87
87
  else:
88
88
  origin = "http://" + host
89
- h = pool.get_connection(origin, timeout=req.timeout)
90
- h.set_debuglevel(self._debuglevel) # type: ignore
91
- headers = dict(req.unredirected_hdrs)
92
- headers.update({k: v for k, v in req.headers.items()
93
- if k not in headers})
89
+ con = pool.get_connection(origin, timeout=req.timeout)
90
+ con.set_debuglevel(self._debuglevel) # type: ignore
91
+ headers = dict_map(req.unredirected_hdrs or (), key=str.lower)
92
+ headers.update({k0: v for k, v in req.headers.items()
93
+ if (k0 := k.lower()) not in headers})
94
94
  headers.setdefault("connection", "keep-alive")
95
95
  if req._tunnel_host:
96
96
  tunnel_headers = {}
97
- proxy_auth_hdr = "Proxy-Authorization"
97
+ proxy_auth_hdr = "proxy-authorization"
98
98
  if proxy_auth_hdr in headers:
99
99
  tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
100
100
  del headers[proxy_auth_hdr]
101
- h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
101
+ con.set_tunnel(req._tunnel_host, headers=tunnel_headers)
102
102
  else:
103
- h._tunnel_host = None
104
- h._tunnel_port = None
105
- h._tunnel_headers.clear()
103
+ con.set_tunnel()
106
104
  try:
107
105
  try:
108
- h.request(req.get_method(), req.selector, req.data, headers,
109
- encode_chunked=req.has_header('Transfer-encoding'))
106
+ con.request(req.get_method(), req.selector, req.data, headers,
107
+ encode_chunked=req.has_header('Transfer-encoding'))
110
108
  except OSError as err:
111
109
  raise URLError(err)
112
- r = h.getresponse()
110
+ r = con.getresponse()
113
111
  except:
114
- pool.return_connection(h)
112
+ pool.return_connection(con)
115
113
  raise
116
114
  r.url = req.get_full_url()
117
115
  r.msg = r.reason
118
116
  if headers.get("connection") == "keep-alive":
119
117
  setattr(r, "pool", pool)
120
- setattr(r, "connection", h)
118
+ setattr(r, "connection", con)
121
119
  return r
122
120
 
123
121