Introduce granular QPACK encoder/decoder stream error codes.
Add new error codes to QpackInstructionDecoder. This class is used by
QpackEncoderStreamReceived to decode the encoder stream, by
QpackDecoderStreamReceived to decode the decoder stream, and by
QpackProgressiveDecoder to decode header blocks. Ignore error codes in
QpackProgressiveDecoder because header block decoding errors are stream errors,
not connection close errors, and unlike CONNECTION_CLOSE frames, RESET_STREAM
frames are not able to convey any extra information other than the mandatory
generic error code. Convert QpackInstructionDecoder::ErrorCode error codes to
newly added QuicErrorCodes in
QpackEncoderStreamReceiver::OnInstructionDecodingError() and
QpackDecoderStreamReceiver::OnInstructionDecodingError().
QPACK encoder stream errors are detected in QpackEncoderStreamReceiver and in
QpackDecoder. Swap all QuicErrorCodes to the new ones, and gate them by the
flag in a single place, in QpackDecoder::OnErrorDetected(). Do the same thing
for QPACK decoder stream errors in QpackDecoderStreamReceiver and QpackEncoder.
Protected by FLAGS_quic_reloadable_flag_quic_granular_qpack_error_codes.
PiperOrigin-RevId: 338170616
Change-Id: I40fbf1c04869d74984e20f48c317daa995b6e99d
diff --git a/quic/core/qpack/qpack_instruction_decoder.cc b/quic/core/qpack/qpack_instruction_decoder.cc
index b4c6dd3..539e310 100644
--- a/quic/core/qpack/qpack_instruction_decoder.cc
+++ b/quic/core/qpack/qpack_instruction_decoder.cc
@@ -183,7 +183,7 @@
state_ = State::kVarintResume;
return true;
case http2::DecodeStatus::kDecodeError:
- OnError("Encoded integer too large.");
+ OnError(ErrorCode::INTEGER_TOO_LARGE, "Encoded integer too large.");
return false;
default:
QUIC_BUG << "Unknown decode status " << status;
@@ -212,7 +212,7 @@
DCHECK(buffer.Empty());
return true;
case http2::DecodeStatus::kDecodeError:
- OnError("Encoded integer too large.");
+ OnError(ErrorCode::INTEGER_TOO_LARGE, "Encoded integer too large.");
return false;
default:
QUIC_BUG << "Unknown decode status " << status;
@@ -244,7 +244,7 @@
string_length_ = varint_decoder_.value();
if (string_length_ > kStringLiteralLengthLimit) {
- OnError("String literal too long.");
+ OnError(ErrorCode::STRING_LITERAL_TOO_LONG, "String literal too long.");
return false;
}
@@ -298,7 +298,8 @@
std::string decoded_value;
huffman_decoder_.Decode(*string, &decoded_value);
if (!huffman_decoder_.InputProperlyTerminated()) {
- OnError("Error in Huffman-encoded string.");
+ OnError(ErrorCode::HUFFMAN_ENCODING_ERROR,
+ "Error in Huffman-encoded string.");
return false;
}
*string = std::move(decoded_value);
@@ -322,11 +323,12 @@
return nullptr;
}
-void QpackInstructionDecoder::OnError(absl::string_view error_message) {
+void QpackInstructionDecoder::OnError(ErrorCode error_code,
+ absl::string_view error_message) {
DCHECK(!error_detected_);
error_detected_ = true;
- delegate_->OnInstructionDecodingError(error_message);
+ delegate_->OnInstructionDecodingError(error_code, error_message);
}
} // namespace quic