Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _decode_headers(decoder, encoded_header_block):
"""
Decode a HPACK-encoded header block, translating HPACK exceptions into
sensible hyper-h2 errors.
This only ever returns bytestring headers: hyper-h2 may emit them as
unicode later, but internally it processes them as bytestrings only.
"""
try:
return decoder.decode(encoded_header_block, raw=True)
except OversizedHeaderListError as e:
# This is a symptom of a HPACK bomb attack: the user has
# disregarded our requirements on how large a header block we'll
# accept.
raise DenialOfServiceError("Oversized header block: %s" % e)
except (HPACKError, IndexError, TypeError, UnicodeDecodeError) as e:
# We should only need HPACKError here, but versions of HPACK older
# than 2.1.0 throw all three others as well. For maximum
# compatibility, catch all of them.
raise ProtocolError("Error decoding header block: %s" % e)
def _decode_headers(decoder, encoded_header_block):
"""
Decode a HPACK-encoded header block, translating HPACK exceptions into
sensible hyper-h2 errors.
This only ever returns bytestring headers: hyper-h2 may emit them as
unicode later, but internally it processes them as bytestrings only.
"""
try:
return decoder.decode(encoded_header_block, raw=True)
except OversizedHeaderListError as e:
# This is a symptom of a HPACK bomb attack: the user has
# disregarded our requirements on how large a header block we'll
# accept.
raise DenialOfServiceError("Oversized header block: %s" % e)
except (HPACKError, IndexError, TypeError, UnicodeDecodeError) as e:
# We should only need HPACKError here, but versions of HPACK older
# than 2.1.0 throw all three others as well. For maximum
# compatibility, catch all of them.
raise ProtocolError("Error decoding header block: %s" % e)
def _decode_headers(decoder, encoded_header_block):
"""
Decode a HPACK-encoded header block, translating HPACK exceptions into
sensible hyper-h2 errors.
This only ever returns bytestring headers: hyper-h2 may emit them as
unicode later, but internally it processes them as bytestrings only.
"""
try:
return decoder.decode(encoded_header_block, raw=True)
except OversizedHeaderListError as e:
# This is a symptom of a HPACK bomb attack: the user has
# disregarded our requirements on how large a header block we'll
# accept.
raise DenialOfServiceError("Oversized header block: %s" % e)
except (HPACKError, IndexError, TypeError, UnicodeDecodeError) as e:
# We should only need HPACKError here, but versions of HPACK older
# than 2.1.0 throw all three others as well. For maximum
# compatibility, catch all of them.
raise ProtocolError("Error decoding header block: %s" % e)