Skip to content

Commit

Permalink
🔖 Release 3.6.3 (#120)
Browse files Browse the repository at this point in the history
**Fixed**
- Fixed encoding data with None values and other objects. This was a
regression introduced in our v3. #119

**Changed**
- Various minor performance improvements.
  • Loading branch information
Ousret authored May 6, 2024
1 parent 432a73c commit 6940d55
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 62 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release History
===============

3.6.3 (2024-05-06)
------------------

**Fixed**
- Fixed encoding data with None values and other objects. This was a regression introduced in our v3. #119

**Changed**
- Various minor performance improvements.

3.6.2 (2024-05-02)
------------------

Expand Down
4 changes: 2 additions & 2 deletions src/niquests/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
__url__: str = "https://niquests.readthedocs.io"

__version__: str
__version__ = "3.6.2"
__version__ = "3.6.3"

__build__: int = 0x030602
__build__: int = 0x030603
__author__: str = "Kenneth Reitz"
__author_email__: str = "[email protected]"
__license__: str = "Apache-2.0"
Expand Down
25 changes: 14 additions & 11 deletions src/niquests/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,20 @@ async def _redirect_method_ref(x, y):
kwargs["on_post_connection"] = None

# we intentionally set 'niquests' as the prefix. urllib3.future have its own parameters.
r._promise.set_parameter("niquests_is_stream", stream)
r._promise.set_parameter("niquests_start", start)
r._promise.set_parameter("niquests_hooks", hooks)
r._promise.set_parameter("niquests_cookies", self.cookies)
r._promise.set_parameter("niquests_allow_redirect", allow_redirects)
r._promise.set_parameter("niquests_kwargs", kwargs)

# You may be wondering why we are setting redirect info in promise ctx.
# because in multiplexed mode, we are not fully aware of hop/redirect count
r._promise.set_parameter("niquests_redirect_count", 0)
r._promise.set_parameter("niquests_max_redirects", self.max_redirects)
r._promise.update_parameters(
{
"niquests_is_stream": stream,
"niquests_start": start,
"niquests_hooks": hooks,
"niquests_cookies": self.cookies,
"niquests_allow_redirect": allow_redirects,
"niquests_kwargs": kwargs,
# You may be wondering why we are setting redirect info in promise ctx.
# because in multiplexed mode, we are not fully aware of hop/redirect count
"niquests_redirect_count": 0,
"niquests_max_redirects": self.max_redirects,
}
)

if not stream:
_swap_context(r)
Expand Down
59 changes: 21 additions & 38 deletions src/niquests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,26 +968,18 @@ def send(
def _future_handler(
self, response: Response, low_resp: BaseHTTPResponse
) -> Response | None:
stream = typing.cast(
bool, response._promise.get_parameter("niquests_is_stream")
)
start = typing.cast(float, response._promise.get_parameter("niquests_start"))
hooks = typing.cast(HookType, response._promise.get_parameter("niquests_hooks"))
session_cookies = typing.cast(
CookieJar, response._promise.get_parameter("niquests_cookies")
)
allow_redirects = typing.cast(
bool, response._promise.get_parameter("niquests_allow_redirect")
)
max_redirect = typing.cast(
int, response._promise.get_parameter("niquests_max_redirects")
)
redirect_count = typing.cast(
int, response._promise.get_parameter("niquests_redirect_count")
stream: bool = response._promise.get_parameter("niquests_is_stream") # type: ignore[assignment]
start: float = response._promise.get_parameter("niquests_start") # type: ignore[assignment]

hooks: HookType = response._promise.get_parameter("niquests_hooks") # type: ignore[assignment]
session_cookies: CookieJar = response._promise.get_parameter("niquests_cookies") # type: ignore[assignment]
allow_redirects: bool = response._promise.get_parameter( # type: ignore[assignment]
"niquests_allow_redirect"
)
kwargs = typing.cast(
typing.MutableMapping[str, typing.Any],
response._promise.get_parameter("niquests_kwargs"),
max_redirect: int = response._promise.get_parameter("niquests_max_redirects") # type: ignore[assignment]
redirect_count: int = response._promise.get_parameter("niquests_redirect_count") # type: ignore[assignment]
kwargs: typing.MutableMapping[str, typing.Any] = (
response._promise.get_parameter("niquests_kwargs") # type: ignore[assignment]
)

# This mark the response as no longer "lazy"
Expand Down Expand Up @@ -1951,26 +1943,17 @@ async def _future_handler(

assert isinstance(response, AsyncResponse)

stream = typing.cast(
bool, response._promise.get_parameter("niquests_is_stream")
)
start = typing.cast(float, response._promise.get_parameter("niquests_start"))
hooks = typing.cast(HookType, response._promise.get_parameter("niquests_hooks"))
session_cookies = typing.cast(
CookieJar, response._promise.get_parameter("niquests_cookies")
)
allow_redirects = typing.cast(
bool, response._promise.get_parameter("niquests_allow_redirect")
)
max_redirect = typing.cast(
int, response._promise.get_parameter("niquests_max_redirects")
)
redirect_count = typing.cast(
int, response._promise.get_parameter("niquests_redirect_count")
stream: bool = response._promise.get_parameter("niquests_is_stream") # type: ignore[assignment]
start: float = response._promise.get_parameter("niquests_start") # type: ignore[assignment]
hooks: HookType = response._promise.get_parameter("niquests_hooks") # type: ignore[assignment]
session_cookies: CookieJar = response._promise.get_parameter("niquests_cookies") # type: ignore[assignment]
allow_redirects: bool = response._promise.get_parameter( # type: ignore[assignment]
"niquests_allow_redirect"
)
kwargs = typing.cast(
typing.MutableMapping[str, typing.Any],
response._promise.get_parameter("niquests_kwargs"),
max_redirect: int = response._promise.get_parameter("niquests_max_redirects") # type: ignore[assignment]
redirect_count: int = response._promise.get_parameter("niquests_redirect_count") # type: ignore[assignment]
kwargs: typing.MutableMapping[str, typing.Any] = (
response._promise.get_parameter("niquests_kwargs") # type: ignore[assignment]
)

# This mark the response as no longer "lazy"
Expand Down
2 changes: 2 additions & 0 deletions src/niquests/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def extract_cookies_to_jar(

if not (hasattr(response, "_original_response") and response._original_response):
return
if "Set-Cookie" not in response._original_response.msg:
return
# the _original_response field is the wrapped httplib.HTTPResponse object,
req = MockRequest(request)
# pull out the HTTPMessage with the headers and put it in the mock:
Expand Down
25 changes: 14 additions & 11 deletions src/niquests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,17 +1198,20 @@ def handle_upload_progress(
kwargs["on_post_connection"] = None

# we intentionally set 'niquests' as the prefix. urllib3.future have its own parameters.
r._promise.set_parameter("niquests_is_stream", stream)
r._promise.set_parameter("niquests_start", start)
r._promise.set_parameter("niquests_hooks", hooks)
r._promise.set_parameter("niquests_cookies", self.cookies)
r._promise.set_parameter("niquests_allow_redirect", allow_redirects)
r._promise.set_parameter("niquests_kwargs", kwargs)

# You may be wondering why we are setting redirect info in promise ctx.
# because in multiplexed mode, we are not fully aware of hop/redirect count
r._promise.set_parameter("niquests_redirect_count", 0)
r._promise.set_parameter("niquests_max_redirects", self.max_redirects)
r._promise.update_parameters(
{
"niquests_is_stream": stream,
"niquests_start": start,
"niquests_hooks": hooks,
"niquests_cookies": self.cookies,
"niquests_allow_redirect": allow_redirects,
"niquests_kwargs": kwargs,
# You may be wondering why we are setting redirect info in promise ctx.
# because in multiplexed mode, we are not fully aware of hop/redirect count
"niquests_redirect_count": 0,
"niquests_max_redirects": self.max_redirects,
}
)

return r

Expand Down

0 comments on commit 6940d55

Please sign in to comment.