Surface hpack decoder detailed error for header value too long, and put detailed error to quic connection close error details. only change connection close error detail, not protected.
PiperOrigin-RevId: 323008871
Change-Id: I6f41118464ae686fbfeb009c8ac13d83b8fff3f0
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer.cc b/http2/hpack/decoder/hpack_whole_entry_buffer.cc
index da5613e..dc93d1e 100644
--- a/http2/hpack/decoder/hpack_whole_entry_buffer.cc
+++ b/http2/hpack/decoder/hpack_whole_entry_buffer.cc
@@ -9,6 +9,7 @@
#include "net/third_party/quiche/src/http2/platform/api/http2_logging.h"
#include "net/third_party/quiche/src/http2/platform/api/http2_macros.h"
#include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
namespace http2 {
@@ -58,7 +59,7 @@
if (len > max_string_size_bytes_) {
HTTP2_DVLOG(1) << "Name length (" << len << ") is longer than permitted ("
<< max_string_size_bytes_ << ")";
- ReportError(HpackDecodingError::kNameTooLong);
+ ReportError(HpackDecodingError::kNameTooLong, "");
HTTP2_CODE_COUNT_N(decompress_failure_3, 18, 23);
return;
}
@@ -72,7 +73,7 @@
<< Http2HexDump(quiche::QuicheStringPiece(data, len));
DCHECK_EQ(maybe_name_index_, 0u);
if (!error_detected_ && !name_.OnData(data, len)) {
- ReportError(HpackDecodingError::kNameHuffmanError);
+ ReportError(HpackDecodingError::kNameHuffmanError, "");
HTTP2_CODE_COUNT_N(decompress_failure_3, 19, 23);
}
}
@@ -81,7 +82,7 @@
HTTP2_DVLOG(2) << "HpackWholeEntryBuffer::OnNameEnd";
DCHECK_EQ(maybe_name_index_, 0u);
if (!error_detected_ && !name_.OnEnd()) {
- ReportError(HpackDecodingError::kNameHuffmanError);
+ ReportError(HpackDecodingError::kNameHuffmanError, "");
HTTP2_CODE_COUNT_N(decompress_failure_3, 20, 23);
}
}
@@ -91,10 +92,11 @@
<< (huffman_encoded ? "true" : "false") << ", len=" << len;
if (!error_detected_) {
if (len > max_string_size_bytes_) {
- HTTP2_DVLOG(1) << "Value length (" << len
- << ") is longer than permitted (" << max_string_size_bytes_
- << ")";
- ReportError(HpackDecodingError::kValueTooLong);
+ std::string detailed_error = quiche::QuicheStrCat(
+ "Value length (", len, ") of [", name_.str(),
+ "] is longer than permitted (", max_string_size_bytes_, ")");
+ HTTP2_DVLOG(1) << detailed_error;
+ ReportError(HpackDecodingError::kValueTooLong, detailed_error);
HTTP2_CODE_COUNT_N(decompress_failure_3, 21, 23);
return;
}
@@ -107,7 +109,7 @@
<< " data:\n"
<< Http2HexDump(quiche::QuicheStringPiece(data, len));
if (!error_detected_ && !value_.OnData(data, len)) {
- ReportError(HpackDecodingError::kValueHuffmanError);
+ ReportError(HpackDecodingError::kValueHuffmanError, "");
HTTP2_CODE_COUNT_N(decompress_failure_3, 22, 23);
}
}
@@ -118,7 +120,7 @@
return;
}
if (!value_.OnEnd()) {
- ReportError(HpackDecodingError::kValueHuffmanError);
+ ReportError(HpackDecodingError::kValueHuffmanError, "");
HTTP2_CODE_COUNT_N(decompress_failure_3, 23, 23);
return;
}
@@ -138,12 +140,13 @@
listener_->OnDynamicTableSizeUpdate(size);
}
-void HpackWholeEntryBuffer::ReportError(HpackDecodingError error) {
+void HpackWholeEntryBuffer::ReportError(HpackDecodingError error,
+ std::string detailed_error) {
if (!error_detected_) {
HTTP2_DVLOG(1) << "HpackWholeEntryBuffer::ReportError: "
<< HpackDecodingErrorToString(error);
error_detected_ = true;
- listener_->OnHpackDecodeError(error);
+ listener_->OnHpackDecodeError(error, detailed_error);
listener_ = HpackWholeEntryNoOpListener::NoOpListener();
}
}