python-urlopen 0.0.5.2__tar.gz → 0.0.6__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.0.5.2
3
+ Version: 0.0.6
4
4
  Summary: Python urlopen wrapper.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-urlopen
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-urlopen"
3
- version = "0.0.5.2"
3
+ version = "0.0.6"
4
4
  description = "Python urlopen wrapper."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -2,7 +2,7 @@
2
2
  # coding: utf-8
3
3
 
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
- __version__ = (0, 0, 5)
5
+ __version__ = (0, 0, 6)
6
6
  __all__ = ["urlopen", "request", "download"]
7
7
 
8
8
  import errno
@@ -27,7 +27,7 @@ from zlib import compressobj, DEF_MEM_LEVEL, DEFLATED, MAX_WBITS
27
27
 
28
28
  from argtools import argcount
29
29
  from brotli import decompress as decompress_br # type: ignore
30
- from filewrap import bio_skip_iter, SupportsRead, SupportsWrite
30
+ from filewrap import bio_skip_iter, SupportsWrite
31
31
  from http_response import get_filename, get_length, is_chunked, is_range_request
32
32
  from zstandard import decompress as decompress_zstd
33
33
 
@@ -87,8 +87,8 @@ def urlopen(
87
87
  timeout: None | int | float = None,
88
88
  cookies: None | CookieJar = None,
89
89
  proxy: None | tuple[str, str] = None,
90
- opener: None | OpenerDirector = None,
91
90
  context: None | SSLContext = None,
91
+ opener: OpenerDirector = build_opener(HTTPSHandler(context=_create_unverified_context())),
92
92
  origin: None | str = None,
93
93
  ) -> HTTPResponse:
94
94
  if isinstance(url, str) and not urlsplit(url).scheme:
@@ -137,8 +137,8 @@ def urlopen(
137
137
  req = Request(url, data=data, headers=headers or {}, method=method.upper())
138
138
  if proxy:
139
139
  req.set_proxy(*proxy)
140
- if opener is None:
141
- opener = build_opener(HTTPSHandler(context=_create_unverified_context()))
140
+ if context is not None or cookies is not None:
141
+ opener = copy(opener)
142
142
  if context is not None:
143
143
  opener.add_handler(HTTPSHandler(context=context))
144
144
  if cookies is not None:
File without changes