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

fix: No more BytesWarnings #1286

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/h2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .frame_buffer import FrameBuffer
from .settings import Settings, SettingCodes
from .stream import H2Stream, StreamClosedBy
from .utilities import SizeLimitDict, guard_increment_window
from .utilities import SizeLimitDict, guard_increment_window, utf8_encode_headers
from .windows import WindowManager


Expand Down Expand Up @@ -976,6 +976,7 @@ def push_stream(self, stream_id, promised_stream_id, request_headers):
)
self.streams[promised_stream_id] = new_stream

request_headers = utf8_encode_headers(request_headers)
frames = stream.push_stream_in_band(
promised_stream_id, request_headers, self.encoder
)
Expand Down
7 changes: 5 additions & 2 deletions src/h2/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from .utilities import (
guard_increment_window, is_informational_response, authority_from_headers,
validate_headers, validate_outbound_headers, normalize_outbound_headers,
HeaderValidationFlags, extract_method_header, normalize_inbound_headers
HeaderValidationFlags, extract_method_header, normalize_inbound_headers,
utf8_encode_headers
)
from .windows import WindowManager

Expand Down Expand Up @@ -851,6 +852,8 @@ def send_headers(self, headers, encoder, end_stream=False):
# we need to scan the header block to see if this is an informational
# response.
input_ = StreamInputs.SEND_HEADERS

headers = utf8_encode_headers(headers)
if ((not self.state_machine.client) and
is_informational_response(headers)):
if end_stream:
Expand Down Expand Up @@ -1319,7 +1322,7 @@ def _initialize_content_length(self, headers):
self._expected_content_length = int(v, 10)
except ValueError:
raise ProtocolError(
"Invalid content-length header: %s" % v
f"Invalid content-length header: {repr(v)}"
Kriechi marked this conversation as resolved.
Show resolved Hide resolved
)

return
Expand Down
Loading
Loading