Dump header name and value length (not value itself) if value too long.

gfe-relnote: Log only change, not protected.
PiperOrigin-RevId: 296224216
Change-Id: I3386574bf73b295d9362b5d20291d299f1a85b3a
diff --git a/http2/hpack/decoder/hpack_decoder.cc b/http2/hpack/decoder/hpack_decoder.cc
index 1013292..bca83db 100644
--- a/http2/hpack/decoder/hpack_decoder.cc
+++ b/http2/hpack/decoder/hpack_decoder.cc
@@ -66,6 +66,10 @@
     HTTP2_CODE_COUNT_N(decompress_failure_3, 4, 23);
     return false;
   } else if (DetectError()) {
+    if (error_ == HpackDecodingError::kValueTooLong) {
+      HTTP2_LOG_FIRST_N(ERROR, 1) << "Header value too long for header name: "
+                                  << entry_buffer_.name().str();
+    }
     HTTP2_CODE_COUNT_N(decompress_failure_3, 5, 23);
     return false;
   }
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer.cc b/http2/hpack/decoder/hpack_whole_entry_buffer.cc
index da5613e..de26c0d 100644
--- a/http2/hpack/decoder/hpack_whole_entry_buffer.cc
+++ b/http2/hpack/decoder/hpack_whole_entry_buffer.cc
@@ -94,6 +94,9 @@
       HTTP2_DVLOG(1) << "Value length (" << len
                      << ") is longer than permitted (" << max_string_size_bytes_
                      << ")";
+      HTTP2_LOG_FIRST_N(ERROR, 1)
+          << "Header value length " << len << " exceeds limit of "
+          << max_string_size_bytes_;
       ReportError(HpackDecodingError::kValueTooLong);
       HTTP2_CODE_COUNT_N(decompress_failure_3, 21, 23);
       return;
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer.h b/http2/hpack/decoder/hpack_whole_entry_buffer.h
index 5c0bfe2..27eb718 100644
--- a/http2/hpack/decoder/hpack_whole_entry_buffer.h
+++ b/http2/hpack/decoder/hpack_whole_entry_buffer.h
@@ -79,6 +79,8 @@
   void OnValueEnd() override;
   void OnDynamicTableSizeUpdate(size_t size) override;
 
+  const HpackDecoderStringBuffer& name() const { return name_; }
+
  private:
   void ReportError(HpackDecodingError error);
 
diff --git a/http2/platform/api/http2_logging.h b/http2/platform/api/http2_logging.h
index cd93ac3..d73c49c 100644
--- a/http2/platform/api/http2_logging.h
+++ b/http2/platform/api/http2_logging.h
@@ -19,4 +19,6 @@
 
 #define HTTP2_DLOG_EVERY_N(severity, n) HTTP2_DLOG_EVERY_N_IMPL(severity, n)
 
+#define HTTP2_LOG_FIRST_N(severity, n) HTTP2_LOG_FIRST_N_IMPL(severity, n)
+
 #endif  // QUICHE_HTTP2_PLATFORM_API_HTTP2_LOGGING_H_