Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔖 Release 3.1.1 #36

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release History
===============

3.1.1 (2023-10-11)
------------------

**Fixed**
- Fixed `Transfer-Encoding` wrongfully added to headers when body is actually of length 0. Due to ambiguous return of `super_len` in niquests internals.
- Fixed accepting three-valued tuple for Timeout (connect, read, total) in addition of known (connect, read) tuple.

3.1.0 (2023-10-10)
------------------

Expand Down
10 changes: 0 additions & 10 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ Authentication
.. autoclass:: niquests.auth.HTTPProxyAuth
.. autoclass:: niquests.auth.HTTPDigestAuth



Encodings
---------

.. autofunction:: niquests.utils.get_encodings_from_content
.. autofunction:: niquests.utils.get_encoding_from_headers
.. autofunction:: niquests.utils.get_unicode_from_response


.. _api-cookies:

Cookies
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.1.0"
__version__ = "3.1.1"

__build__: int = 0x030100
__build__: int = 0x030101
__author__: str = "Kenneth Reitz"
__author_email__: str = "[email protected]"
__license__: str = "Apache-2.0"
Expand Down
14 changes: 10 additions & 4 deletions src/niquests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,21 @@ def send(
proxies=proxies,
)

chunked = not (request.body is None or "Content-Length" in request.headers)
chunked = not (
bool(request.body) is False or "Content-Length" in request.headers
)

if isinstance(timeout, tuple):
try:
connect, read = timeout
timeout = TimeoutSauce(connect=connect, read=read)
if len(timeout) == 3:
connect, read, total = timeout # type: ignore[assignment]
else:
connect, read = timeout # type: ignore[assignment]
total = None
timeout = TimeoutSauce(connect=connect, read=read, total=total)
except ValueError:
raise ValueError(
f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, "
f"Invalid timeout {timeout}. Pass a (connect, read) or (connect, read, total) timeout tuple, "
f"or a single float to set both timeouts to the same value."
)
elif isinstance(timeout, TimeoutSauce):
Expand Down
2 changes: 2 additions & 0 deletions src/niquests/extensions/_ocsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from ..exceptions import RequestException, SSLError
from ..models import PreparedRequest
from ._picotls import (
ALERT,
CHANGE_CIPHER,
HANDSHAKE,
derive_secret,
Expand Down Expand Up @@ -180,6 +181,7 @@ def _ask_nicely_for_issuer(
for der in der_certificates:
certificates.append(load_der_x509_certificate(der))

send_tls(sock, ALERT, b"\x01\x00")
sock.close()

if len(certificates) <= 1:
Expand Down
2 changes: 1 addition & 1 deletion src/niquests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def prepare_body(

if length:
self.headers["Content-Length"] = str(length)
else:
elif body:
self.headers["Transfer-Encoding"] = "chunked"
else:
# Multi-part file uploads.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,7 @@ def test_stream_timeout(self, httpbin):
@pytest.mark.parametrize(
"timeout, error_text",
(
((3, 4, 5), "(connect, read)"),
((3, 4, 5, 5), "(connect, read, total)"),
("foo", "must be an int, float or None"),
),
)
Expand Down