Skip to content
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
19 changes: 10 additions & 9 deletions pcapkit/protocols/application/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ def _guess_version(self, length: 'int', **kwargs: 'Any') -> 'HTTP':
#
# Identified means *committed*: a malformed HTTP/1 message is reported as
# such instead of being handed to the HTTP/2 arm, which accepts any
# self-consistent buffer of nine octets or more. Retrying an identified
# HTTP/1 payload as HTTP/2 is how HTTP/1 traffic acquires a confident
# HTTP/2 mislabel.
# self-consistent buffer of nine octets or more whose header passes
# :func:`_test_http2_frame`. Retrying an identified HTTP/1 payload as
# HTTP/2 is how HTTP/1 traffic acquires a confident HTTP/2 mislabel.
#
# Nothing is suppressed on this arm, deliberately: it is not a candidate
# to be declined, so there is nothing to decline *to*, and
Expand Down Expand Up @@ -430,12 +430,13 @@ def _guess_version(self, length: 'int', **kwargs: 'Any') -> 'HTTP':
# :class:`~pcapkit.utilities.exceptions.StructError` *subclasses*
# :exc:`struct.error`, so suppressing it on a non-final arm swallows
# pcapkit's own signal and hands the payload to the arm below, which
# accepts anything of at least nine octets. With a fault injected at arm
# 1, a *valid* HTTP/1.1 request came back ``version='2'``, and over UDP
# port 80 its ``protochain`` read ``UDP:HTTP/2``. A confident HTTP/2
# mislabel of HTTP/1 traffic is worse than letting the error escape to
# ``beholder``, which turns it into ``Raw``; it would also erase
# ``StructError.eof``, which ``NoPayload`` handling reads.
# accepts any self-consistent buffer whose header passes
# :func:`_test_http2_frame`. With a fault injected at arm 1 and without
# that test, a *valid* HTTP/1.1 request came back ``version='2'``, and
# over UDP port 80 its ``protochain`` read ``UDP:HTTP/2``. A confident
# HTTP/2 mislabel of HTTP/1 traffic is worse than letting the error
# escape to ``beholder``, which turns it into ``Raw``; it would also
# erase ``StructError.eof``, which ``NoPayload`` handling reads.
with contextlib.suppress(ProtocolError):
return HTTPv1(self._data, length, **kwargs)

Expand Down
6 changes: 3 additions & 3 deletions pcapkit/protocols/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,9 +1854,9 @@ def _parse_next_layer(klass: 'Type[ProtocolBase]', file_: 'bytes', length: 'int'
Such a payload is kept as :class:`~pcapkit.protocols.misc.raw.Raw`
instead, as an unparseable one is.

The captured octets are what ``file_`` holds, which may be fewer than
the ``length`` the current header declares. They are short of the
header when there are fewer than the next layer's
The captured octets are the first ``length`` of ``file_``, or all of
it when it holds fewer, as a truncated capture does. They are short
of the header when there are fewer than the next layer's
:meth:`__length_hint__ <ProtocolBase.__length_hint__>`, unless the
header it parsed, :attr:`length <ProtocolBase.length>` octets long, fits
in them anyway: for a variable-length header such as
Expand Down
Loading