Skip to content

Commit

Permalink
Further improved the reliability of the qpack encoder/decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed May 6, 2024
1 parent b99c785 commit d295565
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.6 (2024-05-06)
=====================

**Changed**
- Further improved the reliability of the qpack encoder/decoder.

1.0.5 (2024-05-04)
=====================

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qh3"
version = "1.0.5"
version = "1.0.6"
edition = "2021"
rust-version = "1.75"
license = "BSD-3"
Expand Down
2 changes: 1 addition & 1 deletion qh3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .quic.packet import QuicProtocolVersion
from .tls import CipherSuite, SessionTicket

__version__ = "1.0.5"
__version__ = "1.0.6"

__all__ = (
"connect",
Expand Down
4 changes: 3 additions & 1 deletion qh3/_hazmat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class QpackDecoder:
def feed_header(
self, stream_id: int, data: bytes
) -> tuple[bytes, list[tuple[bytes, bytes]]]: ...
def resume_header(self, stream_id: int) -> list[tuple[bytes, bytes]]: ...
def resume_header(
self, stream_id: int
) -> tuple[bytes, list[tuple[bytes, bytes]]]: ...

class QpackEncoder:
def apply_settings(
Expand Down
10 changes: 7 additions & 3 deletions qh3/h3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ def _decode_headers(self, stream_id: int, frame_data: Optional[bytes]) -> Header
"""
try:
if frame_data is None:
decoder, headers = b"", self._blocked_stream_map[stream_id]._headers # type: ignore[attr-defined]
decoder, headers = self._blocked_stream_map[stream_id]._pending # type: ignore[attr-defined]
del self._blocked_stream_map[stream_id]._pending # type: ignore[attr-defined]
else:
# todo: investigate why the underlying implementation
# seems to ignore bad frames..
Expand Down Expand Up @@ -1059,8 +1060,11 @@ def _receive_stream_data_uni(

for blocked_id, blocked_stream in self._blocked_stream_map.items():
try:
headers = self._decoder.resume_header(blocked_id)
blocked_stream._headers = headers
stream_data, headers = self._decoder.resume_header(blocked_id)
blocked_stream._pending = (
stream_data,
headers,
)
unblocked_streams.add(blocked_id)
except StreamBlocked:
continue
Expand Down
10 changes: 8 additions & 2 deletions src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl QpackDecoder {
}
}

pub fn resume_header<'a>(&mut self, py: Python<'a>, stream_id: u64) -> PyResult<&'a PyList> {
pub fn resume_header<'a>(&mut self, py: Python<'a>, stream_id: u64) -> PyResult<&'a PyTuple> {
let output = self.decoder.unblocked(StreamId::new(stream_id));

if !output.is_some() {
Expand Down Expand Up @@ -195,7 +195,13 @@ impl QpackDecoder {
);
}

return Ok(decoded_headers);
return Ok(PyTuple::new(
py,
[
PyBytes::new(py, buffer.stream()).to_object(py),
decoded_headers.to_object(py),
]
));
},
Ok(DecoderOutput::BlockedStream) => {
return Err(StreamBlocked::new_err("stream is blocked, need more data to pursue decoding"))
Expand Down

0 comments on commit d295565

Please sign in to comment.