summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/qpack
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-12 09:13:00 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-16 09:58:26 +0000
commit03561cae90f1d99b5c54b1ef3be69f10e882b25e (patch)
treecc5f0958e823c044e7ae51cc0117fe51432abe5e /chromium/net/third_party/quiche/src/quic/core/qpack
parentfa98118a45f7e169f8846086dc2c22c49a8ba310 (diff)
downloadqtwebengine-chromium-03561cae90f1d99b5c54b1ef3be69f10e882b25e.tar.gz
BASELINE: Update Chromium to 88.0.4324.208
Change-Id: I3ae87d23e4eff4b4a469685658740a213600c667 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/core/qpack')
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc11
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h14
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc34
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc64
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h20
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc18
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h11
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc47
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc2
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc45
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc276
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc52
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h29
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc27
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h18
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc77
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc8
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h8
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc30
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc231
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc11
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h10
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc22
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc33
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h31
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc87
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc53
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h34
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc15
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc14
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h23
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc6
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc25
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h17
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc6
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc40
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc12
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc10
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc6
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h4
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc21
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h22
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc24
48 files changed, 861 insertions, 707 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc
index 6469dd266b5..1e66346cdb3 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc
@@ -4,9 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -27,9 +27,8 @@ QpackDecodedHeadersAccumulator::QpackDecodedHeadersAccumulator(
quic_header_list_.OnHeaderBlockStart();
}
-void QpackDecodedHeadersAccumulator::OnHeaderDecoded(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+void QpackDecodedHeadersAccumulator::OnHeaderDecoded(absl::string_view name,
+ absl::string_view value) {
DCHECK(!error_detected_);
uncompressed_header_bytes_without_overhead_ += name.size() + value.size();
@@ -64,7 +63,7 @@ void QpackDecodedHeadersAccumulator::OnDecodingCompleted() {
}
void QpackDecodedHeadersAccumulator::OnDecodingErrorDetected(
- quiche::QuicheStringPiece error_message) {
+ absl::string_view error_message) {
DCHECK(!error_detected_);
DCHECK(!headers_decoded_);
@@ -73,7 +72,7 @@ void QpackDecodedHeadersAccumulator::OnDecodingErrorDetected(
visitor_->OnHeaderDecodingError(error_message);
}
-void QpackDecodedHeadersAccumulator::Decode(quiche::QuicheStringPiece data) {
+void QpackDecodedHeadersAccumulator::Decode(absl::string_view data) {
DCHECK(!error_detected_);
compressed_header_bytes_ += data.size();
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h
index 334fcbda543..e194a98ebc5 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h
@@ -8,11 +8,11 @@
#include <cstddef>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -45,8 +45,7 @@ class QUIC_EXPORT_PRIVATE QpackDecodedHeadersAccumulator
bool header_list_size_limit_exceeded) = 0;
// Called when an error has occurred.
- virtual void OnHeaderDecodingError(
- quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnHeaderDecodingError(absl::string_view error_message) = 0;
};
QpackDecodedHeadersAccumulator(QuicStreamId id,
@@ -57,16 +56,15 @@ class QUIC_EXPORT_PRIVATE QpackDecodedHeadersAccumulator
// QpackProgressiveDecoder::HeadersHandlerInterface implementation.
// These methods should only be called by |decoder_|.
- void OnHeaderDecoded(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) override;
+ void OnHeaderDecoded(absl::string_view name,
+ absl::string_view value) override;
void OnDecodingCompleted() override;
- void OnDecodingErrorDetected(
- quiche::QuicheStringPiece error_message) override;
+ void OnDecodingErrorDetected(absl::string_view error_message) override;
// Decode payload data.
// Must not be called if an error has been detected.
// Must not be called after EndHeaderBlock().
- void Decode(quiche::QuicheStringPiece data);
+ void Decode(absl::string_view data);
// Signal end of HEADERS frame.
// Must not be called if an error has been detected.
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
index 93e2561f367..2a5b0da86bf 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
@@ -6,11 +6,12 @@
#include <cstring>
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
using ::testing::_;
@@ -48,7 +49,7 @@ class MockVisitor : public QpackDecodedHeadersAccumulator::Visitor {
(override));
MOCK_METHOD(void,
OnHeaderDecodingError,
- (quiche::QuicheStringPiece error_message),
+ (absl::string_view error_message),
(override));
};
@@ -84,7 +85,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, EmptyPayload) {
// HEADERS frame payload must have a complete Header Block Prefix.
TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedHeaderBlockPrefix) {
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("00"));
+ accumulator_.Decode(absl::HexStringToBytes("00"));
EXPECT_CALL(visitor_,
OnHeaderDecodingError(Eq("Incomplete header data prefix.")));
@@ -92,7 +93,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedHeaderBlockPrefix) {
}
TEST_F(QpackDecodedHeadersAccumulatorTest, EmptyHeaderList) {
- std::string encoded_data(quiche::QuicheTextUtils::HexDecode("0000"));
+ std::string encoded_data(absl::HexStringToBytes("0000"));
accumulator_.Decode(encoded_data);
QuicHeaderList header_list;
@@ -108,7 +109,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, EmptyHeaderList) {
// This payload is the prefix of a valid payload, but EndHeaderBlock() is called
// before it can be completely decoded.
TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedPayload) {
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("00002366"));
+ accumulator_.Decode(absl::HexStringToBytes("00002366"));
EXPECT_CALL(visitor_, OnHeaderDecodingError(Eq("Incomplete header block.")));
accumulator_.EndHeaderBlock();
@@ -118,12 +119,11 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedPayload) {
TEST_F(QpackDecodedHeadersAccumulatorTest, InvalidPayload) {
EXPECT_CALL(visitor_,
OnHeaderDecodingError(Eq("Static table entry not found.")));
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("0000ff23ff24"));
+ accumulator_.Decode(absl::HexStringToBytes("0000ff23ff24"));
}
TEST_F(QpackDecodedHeadersAccumulatorTest, Success) {
- std::string encoded_data(
- quiche::QuicheTextUtils::HexDecode("000023666f6f03626172"));
+ std::string encoded_data(absl::HexStringToBytes("000023666f6f03626172"));
accumulator_.Decode(encoded_data);
QuicHeaderList header_list;
@@ -141,7 +141,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, Success) {
// otherwise decoding could fail with "incomplete header block" error.
TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitThenSplitInstruction) {
// Total length of header list exceeds kMaxHeaderListSize.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode(
+ accumulator_.Decode(absl::HexStringToBytes(
"0000" // header block prefix
"26666f6f626172" // header key: "foobar"
"7d61616161616161616161616161616161616161" // header value: 'a' 125 times
@@ -149,7 +149,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitThenSplitInstruction) {
"616161616161616161616161616161616161616161616161616161616161616161616161"
"61616161616161616161616161616161616161616161616161616161616161616161"
"ff")); // first byte of a two-byte long Indexed Header Field instruction
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode(
+ accumulator_.Decode(absl::HexStringToBytes(
"0f" // second byte of a two-byte long Indexed Header Field instruction
));
@@ -160,7 +160,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitThenSplitInstruction) {
// Test that header list limit enforcement works with blocked encoding.
TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitBlocked) {
// Total length of header list exceeds kMaxHeaderListSize.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode(
+ accumulator_.Decode(absl::HexStringToBytes(
"0200" // header block prefix
"80" // reference to dynamic table entry not yet received
"26666f6f626172" // header key: "foobar"
@@ -182,7 +182,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitBlocked) {
TEST_F(QpackDecodedHeadersAccumulatorTest, BlockedDecoding) {
// Reference to dynamic table entry not yet received.
- std::string encoded_data(quiche::QuicheTextUtils::HexDecode("020080"));
+ std::string encoded_data(absl::HexStringToBytes("020080"));
accumulator_.Decode(encoded_data);
accumulator_.EndHeaderBlock();
@@ -206,7 +206,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, BlockedDecoding) {
TEST_F(QpackDecodedHeadersAccumulatorTest,
BlockedDecodingUnblockedBeforeEndOfHeaderBlock) {
// Reference to dynamic table entry not yet received.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("020080"));
+ accumulator_.Decode(absl::HexStringToBytes("020080"));
// Set dynamic table capacity.
qpack_decoder_.OnSetDynamicTableCapacity(kMaxDynamicTableCapacity);
@@ -216,7 +216,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest,
// Rest of header block: same entry again.
EXPECT_CALL(decoder_stream_sender_delegate_,
WriteStreamData(Eq(kHeaderAcknowledgement)));
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("80"));
+ accumulator_.Decode(absl::HexStringToBytes("80"));
QuicHeaderList header_list;
EXPECT_CALL(visitor_, OnHeadersDecoded(_, false))
@@ -231,12 +231,12 @@ TEST_F(QpackDecodedHeadersAccumulatorTest,
BlockedDecodingUnblockedAndErrorBeforeEndOfHeaderBlock) {
// Required Insert Count higher than number of entries causes decoding to be
// blocked.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("0200"));
+ accumulator_.Decode(absl::HexStringToBytes("0200"));
// Indexed Header Field instruction addressing dynamic table entry with
// relative index 0, absolute index 0.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("80"));
+ accumulator_.Decode(absl::HexStringToBytes("80"));
// Relative index larger than or equal to Base is invalid.
- accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("81"));
+ accumulator_.Decode(absl::HexStringToBytes("81"));
// Set dynamic table capacity.
qpack_decoder_.OnSetDynamicTableCapacity(kMaxDynamicTableCapacity);
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc
index 17790defd5f..86383319c33 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc
@@ -6,9 +6,10 @@
#include <utility>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -70,19 +71,19 @@ void QpackDecoder::OnDecodingCompleted(QuicStreamId stream_id,
void QpackDecoder::OnInsertWithNameReference(bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value) {
+ absl::string_view value) {
if (is_static) {
auto entry = header_table_.LookupEntry(/* is_static = */ true, name_index);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Invalid static table entry.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INVALID_STATIC_ENTRY,
+ "Invalid static table entry.");
return;
}
entry = header_table_.InsertEntry(entry->name(), value);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Error inserting entry with name reference.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_STATIC,
+ "Error inserting entry with name reference.");
}
return;
}
@@ -90,32 +91,31 @@ void QpackDecoder::OnInsertWithNameReference(bool is_static,
uint64_t absolute_index;
if (!QpackEncoderStreamRelativeIndexToAbsoluteIndex(
name_index, header_table_.inserted_entry_count(), &absolute_index)) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Invalid relative index.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INSERTION_INVALID_RELATIVE_INDEX,
+ "Invalid relative index.");
return;
}
const QpackEntry* entry =
header_table_.LookupEntry(/* is_static = */ false, absolute_index);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Dynamic table entry not found.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INSERTION_DYNAMIC_ENTRY_NOT_FOUND,
+ "Dynamic table entry not found.");
return;
}
entry = header_table_.InsertEntry(entry->name(), value);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Error inserting entry with name reference.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_DYNAMIC,
+ "Error inserting entry with name reference.");
}
}
-void QpackDecoder::OnInsertWithoutNameReference(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+void QpackDecoder::OnInsertWithoutNameReference(absl::string_view name,
+ absl::string_view value) {
const QpackEntry* entry = header_table_.InsertEntry(name, value);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Error inserting literal entry.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_LITERAL,
+ "Error inserting literal entry.");
}
}
@@ -123,34 +123,44 @@ void QpackDecoder::OnDuplicate(uint64_t index) {
uint64_t absolute_index;
if (!QpackEncoderStreamRelativeIndexToAbsoluteIndex(
index, header_table_.inserted_entry_count(), &absolute_index)) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Invalid relative index.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX,
+ "Invalid relative index.");
return;
}
const QpackEntry* entry =
header_table_.LookupEntry(/* is_static = */ false, absolute_index);
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Dynamic table entry not found.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_DUPLICATE_DYNAMIC_ENTRY_NOT_FOUND,
+ "Dynamic table entry not found.");
return;
}
entry = header_table_.InsertEntry(entry->name(), entry->value());
if (!entry) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Error inserting duplicate entry.");
+ // InsertEntry() can only fail if entry is larger then dynamic table
+ // capacity, but that is impossible since entry was retrieved from the
+ // dynamic table.
+ OnErrorDetected(QUIC_INTERNAL_ERROR, "Error inserting duplicate entry.");
}
}
void QpackDecoder::OnSetDynamicTableCapacity(uint64_t capacity) {
if (!header_table_.SetDynamicTableCapacity(capacity)) {
- encoder_stream_error_delegate_->OnEncoderStreamError(
- "Error updating dynamic table capacity.");
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_SET_DYNAMIC_TABLE_CAPACITY,
+ "Error updating dynamic table capacity.");
}
}
-void QpackDecoder::OnErrorDetected(quiche::QuicheStringPiece error_message) {
- encoder_stream_error_delegate_->OnEncoderStreamError(error_message);
+void QpackDecoder::OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) {
+ if (GetQuicReloadableFlag(quic_granular_qpack_error_codes)) {
+ QUIC_CODE_COUNT_N(quic_granular_qpack_error_codes, 2, 2);
+ encoder_stream_error_delegate_->OnEncoderStreamError(error_code,
+ error_message);
+ } else {
+ encoder_stream_error_delegate_->OnEncoderStreamError(
+ QUIC_QPACK_ENCODER_STREAM_ERROR, error_message);
+ }
}
std::unique_ptr<QpackProgressiveDecoder> QpackDecoder::CreateProgressiveDecoder(
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h
index e09b14bef91..6e0c0ab92a1 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h
@@ -9,19 +9,24 @@
#include <memory>
#include <set>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h"
+#include "net/third_party/quiche/src/quic/core/quic_error_codes.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
// QPACK decoder class. Exactly one instance should exist per QUIC connection.
// This class vends a new QpackProgressiveDecoder instance for each new header
// list to be encoded.
+// QpackProgressiveDecoder detects and signals errors with header blocks, which
+// are stream errors.
+// The only input of QpackDecoder is the encoder stream. Any error QpackDecoder
+// signals is an encoder stream error, which is fatal to the connection.
class QUIC_EXPORT_PRIVATE QpackDecoder
: public QpackEncoderStreamReceiver::Delegate,
public QpackProgressiveDecoder::BlockedStreamLimitEnforcer,
@@ -34,8 +39,8 @@ class QUIC_EXPORT_PRIVATE QpackDecoder
public:
virtual ~EncoderStreamErrorDelegate() {}
- virtual void OnEncoderStreamError(
- quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnEncoderStreamError(QuicErrorCode error_code,
+ absl::string_view error_message) = 0;
};
QpackDecoder(uint64_t maximum_dynamic_table_capacity,
@@ -80,12 +85,13 @@ class QUIC_EXPORT_PRIVATE QpackDecoder
// QpackEncoderStreamReceiver::Delegate implementation
void OnInsertWithNameReference(bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value) override;
- void OnInsertWithoutNameReference(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) override;
+ absl::string_view value) override;
+ void OnInsertWithoutNameReference(absl::string_view name,
+ absl::string_view value) override;
void OnDuplicate(uint64_t index) override;
void OnSetDynamicTableCapacity(uint64_t capacity) override;
- void OnErrorDetected(quiche::QuicheStringPiece error_message) override;
+ void OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) override;
// delegate must be set if dynamic table capacity is not zero.
void set_qpack_stream_sender_delegate(QpackStreamSenderDelegate* delegate) {
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc
index 5d6cf837621..e63d853da20 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc
@@ -4,10 +4,10 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/http2/decoder/decode_buffer.h"
#include "net/third_party/quiche/src/http2/decoder/decode_status.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -18,7 +18,7 @@ QpackDecoderStreamReceiver::QpackDecoderStreamReceiver(Delegate* delegate)
DCHECK(delegate_);
}
-void QpackDecoderStreamReceiver::Decode(quiche::QuicheStringPiece data) {
+void QpackDecoderStreamReceiver::Decode(absl::string_view data) {
if (data.empty() || error_detected_) {
return;
}
@@ -43,12 +43,20 @@ bool QpackDecoderStreamReceiver::OnInstructionDecoded(
return true;
}
-void QpackDecoderStreamReceiver::OnError(
- quiche::QuicheStringPiece error_message) {
+void QpackDecoderStreamReceiver::OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message) {
DCHECK(!error_detected_);
error_detected_ = true;
- delegate_->OnErrorDetected(error_message);
+
+ // There is no string literals on the decoder stream,
+ // the only possible error is INTEGER_TOO_LARGE.
+ QuicErrorCode quic_error_code =
+ (error_code == QpackInstructionDecoder::ErrorCode::INTEGER_TOO_LARGE)
+ ? QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE
+ : QUIC_INTERNAL_ERROR;
+ delegate_->OnErrorDetected(quic_error_code, error_message);
}
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h
index 19f51f0d3b4..b3b3d692cbe 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h
@@ -7,11 +7,12 @@
#include <cstdint>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h"
+#include "net/third_party/quiche/src/quic/core/quic_error_codes.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -34,7 +35,8 @@ class QUIC_EXPORT_PRIVATE QpackDecoderStreamReceiver
// 5.3.3 Stream Cancellation
virtual void OnStreamCancellation(QuicStreamId stream_id) = 0;
// Decoding error
- virtual void OnErrorDetected(quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) = 0;
};
explicit QpackDecoderStreamReceiver(Delegate* delegate);
@@ -47,11 +49,12 @@ class QUIC_EXPORT_PRIVATE QpackDecoderStreamReceiver
// Decode data and call appropriate Delegate method after each decoded
// instruction. Once an error occurs, Delegate::OnErrorDetected() is called,
// and all further data is ignored.
- void Decode(quiche::QuicheStringPiece data) override;
+ void Decode(absl::string_view data) override;
// QpackInstructionDecoder::Delegate implementation.
bool OnInstructionDecoded(const QpackInstruction* instruction) override;
- void OnError(quiche::QuicheStringPiece error_message) override;
+ void OnInstructionDecodingError(QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message) override;
private:
QpackInstructionDecoder instruction_decoder_;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc
index 70d2450662a..fd7959512c8 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc
@@ -4,8 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h"
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
using testing::Eq;
@@ -27,7 +28,7 @@ class MockDelegate : public QpackDecoderStreamReceiver::Delegate {
MOCK_METHOD(void, OnStreamCancellation, (QuicStreamId stream_id), (override));
MOCK_METHOD(void,
OnErrorDetected,
- (quiche::QuicheStringPiece error_message),
+ (QuicErrorCode error_code, absl::string_view error_message),
(override));
};
@@ -42,53 +43,59 @@ class QpackDecoderStreamReceiverTest : public QuicTest {
TEST_F(QpackDecoderStreamReceiverTest, InsertCountIncrement) {
EXPECT_CALL(delegate_, OnInsertCountIncrement(0));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("00"));
+ stream_.Decode(absl::HexStringToBytes("00"));
EXPECT_CALL(delegate_, OnInsertCountIncrement(10));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("0a"));
+ stream_.Decode(absl::HexStringToBytes("0a"));
EXPECT_CALL(delegate_, OnInsertCountIncrement(63));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("3f00"));
+ stream_.Decode(absl::HexStringToBytes("3f00"));
EXPECT_CALL(delegate_, OnInsertCountIncrement(200));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("3f8901"));
+ stream_.Decode(absl::HexStringToBytes("3f8901"));
- EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large.")));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff"));
+ EXPECT_CALL(delegate_,
+ OnErrorDetected(QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
+ stream_.Decode(absl::HexStringToBytes("3fffffffffffffffffffff"));
}
TEST_F(QpackDecoderStreamReceiverTest, HeaderAcknowledgement) {
EXPECT_CALL(delegate_, OnHeaderAcknowledgement(0));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("80"));
+ stream_.Decode(absl::HexStringToBytes("80"));
EXPECT_CALL(delegate_, OnHeaderAcknowledgement(37));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("a5"));
+ stream_.Decode(absl::HexStringToBytes("a5"));
EXPECT_CALL(delegate_, OnHeaderAcknowledgement(127));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("ff00"));
+ stream_.Decode(absl::HexStringToBytes("ff00"));
EXPECT_CALL(delegate_, OnHeaderAcknowledgement(503));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("fff802"));
+ stream_.Decode(absl::HexStringToBytes("fff802"));
- EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large.")));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff"));
+ EXPECT_CALL(delegate_,
+ OnErrorDetected(QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
+ stream_.Decode(absl::HexStringToBytes("ffffffffffffffffffffff"));
}
TEST_F(QpackDecoderStreamReceiverTest, StreamCancellation) {
EXPECT_CALL(delegate_, OnStreamCancellation(0));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("40"));
+ stream_.Decode(absl::HexStringToBytes("40"));
EXPECT_CALL(delegate_, OnStreamCancellation(19));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("53"));
+ stream_.Decode(absl::HexStringToBytes("53"));
EXPECT_CALL(delegate_, OnStreamCancellation(63));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("7f00"));
+ stream_.Decode(absl::HexStringToBytes("7f00"));
EXPECT_CALL(delegate_, OnStreamCancellation(110));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("7f2f"));
+ stream_.Decode(absl::HexStringToBytes("7f2f"));
- EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large.")));
- stream_.Decode(quiche::QuicheTextUtils::HexDecode("7fffffffffffffffffffff"));
+ EXPECT_CALL(delegate_,
+ OnErrorDetected(QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
+ stream_.Decode(absl::HexStringToBytes("7fffffffffffffffffffff"));
}
} // namespace
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc
index 34f4de8d2af..bfb19e10f59 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc
@@ -8,9 +8,9 @@
#include <limits>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc
index 1d18fa92e59..c412c9f78e3 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc
@@ -4,6 +4,7 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h"
+#include "absl/strings/escaping.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
@@ -27,67 +28,55 @@ class QpackDecoderStreamSenderTest : public QuicTest {
};
TEST_F(QpackDecoderStreamSenderTest, InsertCountIncrement) {
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("00"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("00"))));
stream_.SendInsertCountIncrement(0);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("0a"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("0a"))));
stream_.SendInsertCountIncrement(10);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3f00"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("3f00"))));
stream_.SendInsertCountIncrement(63);
stream_.Flush();
- EXPECT_CALL(delegate_, WriteStreamData(
- Eq(quiche::QuicheTextUtils::HexDecode("3f8901"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("3f8901"))));
stream_.SendInsertCountIncrement(200);
stream_.Flush();
}
TEST_F(QpackDecoderStreamSenderTest, HeaderAcknowledgement) {
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("80"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("80"))));
stream_.SendHeaderAcknowledgement(0);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("a5"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("a5"))));
stream_.SendHeaderAcknowledgement(37);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("ff00"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("ff00"))));
stream_.SendHeaderAcknowledgement(127);
stream_.Flush();
- EXPECT_CALL(delegate_, WriteStreamData(
- Eq(quiche::QuicheTextUtils::HexDecode("fff802"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("fff802"))));
stream_.SendHeaderAcknowledgement(503);
stream_.Flush();
}
TEST_F(QpackDecoderStreamSenderTest, StreamCancellation) {
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("40"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("40"))));
stream_.SendStreamCancellation(0);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("53"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("53"))));
stream_.SendStreamCancellation(19);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("7f00"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("7f00"))));
stream_.SendStreamCancellation(63);
stream_.Flush();
- EXPECT_CALL(delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("7f2f"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("7f2f"))));
stream_.SendStreamCancellation(110);
stream_.Flush();
}
@@ -97,16 +86,14 @@ TEST_F(QpackDecoderStreamSenderTest, Coalesce) {
stream_.SendHeaderAcknowledgement(37);
stream_.SendStreamCancellation(0);
- EXPECT_CALL(delegate_, WriteStreamData(
- Eq(quiche::QuicheTextUtils::HexDecode("0aa540"))));
+ EXPECT_CALL(delegate_, WriteStreamData(Eq(absl::HexStringToBytes("0aa540"))));
stream_.Flush();
stream_.SendInsertCountIncrement(63);
stream_.SendStreamCancellation(110);
- EXPECT_CALL(
- delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3f007f2f"))));
+ EXPECT_CALL(delegate_,
+ WriteStreamData(Eq(absl::HexStringToBytes("3f007f2f"))));
stream_.Flush();
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc
index 8b546b0ed9f..cf7c9d39a5c 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc
@@ -6,11 +6,13 @@
#include <algorithm>
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
@@ -49,13 +51,12 @@ class QpackDecoderTest : public QuicTestWithParam<FragmentMode> {
// Destroy QpackProgressiveDecoder on error to test that it does not crash.
// See https://crbug.com/1025209.
ON_CALL(handler_, OnDecodingErrorDetected(_))
- .WillByDefault(
- Invoke([this](quiche::QuicheStringPiece /* error_message */) {
- progressive_decoder_.reset();
- }));
+ .WillByDefault(Invoke([this](absl::string_view /* error_message */) {
+ progressive_decoder_.reset();
+ }));
}
- void DecodeEncoderStreamData(quiche::QuicheStringPiece data) {
+ void DecodeEncoderStreamData(absl::string_view data) {
qpack_decoder_.encoder_stream_receiver()->Decode(data);
}
@@ -71,7 +72,7 @@ class QpackDecoderTest : public QuicTestWithParam<FragmentMode> {
// Pass header block data to QpackProgressiveDecoder::Decode()
// in fragments dictated by |fragment_mode_|.
- void DecodeData(quiche::QuicheStringPiece data) {
+ void DecodeData(absl::string_view data) {
auto fragment_size_generator =
FragmentModeToFragmentSizeGenerator(fragment_mode_);
while (progressive_decoder_ && !data.empty()) {
@@ -91,7 +92,7 @@ class QpackDecoderTest : public QuicTestWithParam<FragmentMode> {
}
// Decode an entire header block.
- void DecodeHeaderBlock(quiche::QuicheStringPiece data) {
+ void DecodeHeaderBlock(absl::string_view data) {
StartDecoding();
DecodeData(data);
EndDecoding();
@@ -117,7 +118,7 @@ TEST_P(QpackDecoderTest, NoPrefix) {
OnDecodingErrorDetected(Eq("Incomplete header data prefix.")));
// Header Data Prefix is at least two bytes long.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00"));
+ DecodeHeaderBlock(absl::HexStringToBytes("00"));
}
// Regression test for https://1025209: QpackProgressiveDecoder must not crash
@@ -129,52 +130,50 @@ TEST_P(QpackDecoderTest, InvalidPrefix) {
OnDecodingErrorDetected(Eq("Encoded integer too large.")));
// Encoded Required Insert Count in Header Data Prefix is too large.
- DecodeData(
- quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffffffffff"));
+ DecodeData(absl::HexStringToBytes("ffffffffffffffffffffffffffff"));
}
TEST_P(QpackDecoderTest, EmptyHeaderBlock) {
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0000"));
+ DecodeHeaderBlock(absl::HexStringToBytes("0000"));
}
TEST_P(QpackDecoderTest, LiteralEntryEmptyName) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq(""), Eq("foo")));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002003666f6f"));
+ DecodeHeaderBlock(absl::HexStringToBytes("00002003666f6f"));
}
TEST_P(QpackDecoderTest, LiteralEntryEmptyValue) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("")));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f00"));
+ DecodeHeaderBlock(absl::HexStringToBytes("000023666f6f00"));
}
TEST_P(QpackDecoderTest, LiteralEntryEmptyNameAndValue) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq(""), Eq("")));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002000"));
+ DecodeHeaderBlock(absl::HexStringToBytes("00002000"));
}
TEST_P(QpackDecoderTest, SimpleLiteralEntry) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f03626172"));
+ DecodeHeaderBlock(absl::HexStringToBytes("000023666f6f03626172"));
}
TEST_P(QpackDecoderTest, MultipleLiteralEntries) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
std::string str(127, 'a');
- EXPECT_CALL(handler_,
- OnHeaderDecoded(Eq("foobaar"), quiche::QuicheStringPiece(str)));
+ EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foobaar"), absl::string_view(str)));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0000" // prefix
"23666f6f03626172" // foo: bar
"2700666f6f62616172" // 7 octet long header name, the smallest number
@@ -192,8 +191,7 @@ TEST_P(QpackDecoderTest, NameLenTooLargeForVarintDecoder) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Encoded integer too large.")));
- DecodeHeaderBlock(
- quiche::QuicheTextUtils::HexDecode("000027ffffffffffffffffffff"));
+ DecodeHeaderBlock(absl::HexStringToBytes("000027ffffffffffffffffffff"));
}
// Name Length value can be decoded by varint decoder but exceeds 1 MB limit.
@@ -201,7 +199,7 @@ TEST_P(QpackDecoderTest, NameLenExceedsLimit) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("String literal too long.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000027ffff7f"));
+ DecodeHeaderBlock(absl::HexStringToBytes("000027ffff7f"));
}
// Value Length value is too large for varint decoder to decode.
@@ -210,7 +208,7 @@ TEST_P(QpackDecoderTest, ValueLenTooLargeForVarintDecoder) {
OnDecodingErrorDetected(Eq("Encoded integer too large.")));
DecodeHeaderBlock(
- quiche::QuicheTextUtils::HexDecode("000023666f6f7fffffffffffffffffffff"));
+ absl::HexStringToBytes("000023666f6f7fffffffffffffffffffff"));
}
// Value Length value can be decoded by varint decoder but exceeds 1 MB limit.
@@ -218,22 +216,22 @@ TEST_P(QpackDecoderTest, ValueLenExceedsLimit) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("String literal too long.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f7fffff7f"));
+ DecodeHeaderBlock(absl::HexStringToBytes("000023666f6f7fffff7f"));
}
TEST_P(QpackDecoderTest, IncompleteHeaderBlock) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Incomplete header block.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002366"));
+ DecodeHeaderBlock(absl::HexStringToBytes("00002366"));
}
TEST_P(QpackDecoderTest, HuffmanSimple) {
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("custom-key"), Eq("custom-value")));
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
- "00002f0125a849e95ba97d7f8925a849e95bb8e8b4bf"));
+ DecodeHeaderBlock(
+ absl::HexStringToBytes("00002f0125a849e95ba97d7f8925a849e95bb8e8b4bf"));
}
TEST_P(QpackDecoderTest, AlternatingHuffmanNonHuffman) {
@@ -241,7 +239,7 @@ TEST_P(QpackDecoderTest, AlternatingHuffmanNonHuffman) {
.Times(4);
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0000" // Prefix.
"2f0125a849e95ba97d7f" // Huffman-encoded name.
"8925a849e95bb8e8b4bf" // Huffman-encoded value.
@@ -254,45 +252,45 @@ TEST_P(QpackDecoderTest, AlternatingHuffmanNonHuffman) {
}
TEST_P(QpackDecoderTest, HuffmanNameDoesNotHaveEOSPrefix) {
- EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece(
+ EXPECT_CALL(handler_, OnDecodingErrorDetected(absl::string_view(
"Error in Huffman-encoded string.")));
// 'y' ends in 0b0 on the most significant bit of the last byte.
// The remaining 7 bits must be a prefix of EOS, which is all 1s.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
- "00002f0125a849e95ba97d7e8925a849e95bb8e8b4bf"));
+ DecodeHeaderBlock(
+ absl::HexStringToBytes("00002f0125a849e95ba97d7e8925a849e95bb8e8b4bf"));
}
TEST_P(QpackDecoderTest, HuffmanValueDoesNotHaveEOSPrefix) {
- EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece(
+ EXPECT_CALL(handler_, OnDecodingErrorDetected(absl::string_view(
"Error in Huffman-encoded string.")));
// 'e' ends in 0b101, taking up the 3 most significant bits of the last byte.
// The remaining 5 bits must be a prefix of EOS, which is all 1s.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
- "00002f0125a849e95ba97d7f8925a849e95bb8e8b4be"));
+ DecodeHeaderBlock(
+ absl::HexStringToBytes("00002f0125a849e95ba97d7f8925a849e95bb8e8b4be"));
}
TEST_P(QpackDecoderTest, HuffmanNameEOSPrefixTooLong) {
- EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece(
+ EXPECT_CALL(handler_, OnDecodingErrorDetected(absl::string_view(
"Error in Huffman-encoded string.")));
// The trailing EOS prefix must be at most 7 bits long. Appending one octet
// with value 0xff is invalid, even though 0b111111111111111 (15 bits) is a
// prefix of EOS.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
- "00002f0225a849e95ba97d7fff8925a849e95bb8e8b4bf"));
+ DecodeHeaderBlock(
+ absl::HexStringToBytes("00002f0225a849e95ba97d7fff8925a849e95bb8e8b4bf"));
}
TEST_P(QpackDecoderTest, HuffmanValueEOSPrefixTooLong) {
- EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece(
+ EXPECT_CALL(handler_, OnDecodingErrorDetected(absl::string_view(
"Error in Huffman-encoded string.")));
// The trailing EOS prefix must be at most 7 bits long. Appending one octet
// with value 0xff is invalid, even though 0b1111111111111 (13 bits) is a
// prefix of EOS.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
- "00002f0125a849e95ba97d7f8a25a849e95bb8e8b4bfff"));
+ DecodeHeaderBlock(
+ absl::HexStringToBytes("00002f0125a849e95ba97d7f8a25a849e95bb8e8b4bfff"));
}
TEST_P(QpackDecoderTest, StaticTable) {
@@ -313,7 +311,7 @@ TEST_P(QpackDecoderTest, StaticTable) {
EXPECT_CALL(handler_, OnDecodingCompleted());
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0000d1dfccd45f108621e9aec2a11f5c8294e75f000554524143455f1000"));
}
@@ -326,11 +324,11 @@ TEST_P(QpackDecoderTest, TooHighStaticTableIndex) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Static table entry not found.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0000ff23ff24"));
+ DecodeHeaderBlock(absl::HexStringToBytes("0000ff23ff24"));
}
TEST_P(QpackDecoderTest, DynamicTable) {
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode(
+ DecodeEncoderStreamData(absl::HexStringToBytes(
"3fe107" // Set dynamic table capacity to 1024.
"6294e703626172" // Add literal entry with name "foo" and value "bar".
"80035a5a5a" // Add entry with name of dynamic table entry index 0
@@ -359,7 +357,7 @@ TEST_P(QpackDecoderTest, DynamicTable) {
.InSequence(s);
EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0500" // Required Insert Count 4 and Delta Base 0.
// Base is 4 + 0 = 4.
"83" // Dynamic table entry with relative index 3, absolute index 0.
@@ -380,7 +378,7 @@ TEST_P(QpackDecoderTest, DynamicTable) {
.InSequence(s);
EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0502" // Required Insert Count 4 and Delta Base 2.
// Base is 4 + 2 = 6.
"85" // Dynamic table entry with relative index 5, absolute index 0.
@@ -401,7 +399,7 @@ TEST_P(QpackDecoderTest, DynamicTable) {
.InSequence(s);
EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0582" // Required Insert Count 4 and Delta Base 2 with sign bit set.
// Base is 4 - 2 - 1 = 1.
"80" // Dynamic table entry with relative index 0, absolute index 0.
@@ -414,28 +412,28 @@ TEST_P(QpackDecoderTest, DynamicTable) {
TEST_P(QpackDecoderTest, DecreasingDynamicTableCapacityEvictsEntries) {
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_, OnDecodingCompleted());
EXPECT_CALL(decoder_stream_sender_delegate_,
WriteStreamData(Eq(kHeaderAcknowledgement)));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80")); // Dynamic table entry with relative index 0, absolute index 0.
// Change dynamic table capacity to 32 bytes, smaller than the entry.
// This must cause the entry to be evicted.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f01"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3f01"));
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Dynamic table entry already evicted.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80")); // Dynamic table entry with relative index 0, absolute index 0.
@@ -443,27 +441,40 @@ TEST_P(QpackDecoderTest, DecreasingDynamicTableCapacityEvictsEntries) {
TEST_P(QpackDecoderTest, EncoderStreamErrorEntryTooLarge) {
EXPECT_CALL(encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Error inserting literal entry.")));
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_LITERAL
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Error inserting literal entry.")));
// Set dynamic table capacity to 34.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f03"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3f03"));
// Add literal entry with name "foo" and value "bar", size is 32 + 3 + 3 = 38.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
}
TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidStaticTableEntry) {
EXPECT_CALL(encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Invalid static table entry.")));
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_INVALID_STATIC_ENTRY
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Invalid static table entry.")));
// Address invalid static table entry index 99.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("ff2400"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("ff2400"));
}
TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidDynamicTableEntry) {
- EXPECT_CALL(encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Invalid relative index.")));
+ EXPECT_CALL(
+ encoder_stream_error_delegate_,
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_INSERTION_INVALID_RELATIVE_INDEX
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Invalid relative index.")));
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode(
+ DecodeEncoderStreamData(absl::HexStringToBytes(
"3fe107" // Set dynamic table capacity to 1024.
"6294e703626172" // Add literal entry with name "foo" and value "bar".
"8100")); // Address dynamic table entry with relative index 1. Such
@@ -472,10 +483,15 @@ TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidDynamicTableEntry) {
}
TEST_P(QpackDecoderTest, EncoderStreamErrorDuplicateInvalidEntry) {
- EXPECT_CALL(encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Invalid relative index.")));
+ EXPECT_CALL(
+ encoder_stream_error_delegate_,
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Invalid relative index.")));
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode(
+ DecodeEncoderStreamData(absl::HexStringToBytes(
"3fe107" // Set dynamic table capacity to 1024.
"6294e703626172" // Add literal entry with name "foo" and value "bar".
"01")); // Duplicate dynamic table entry with relative index 1. Such
@@ -485,21 +501,24 @@ TEST_P(QpackDecoderTest, EncoderStreamErrorDuplicateInvalidEntry) {
TEST_P(QpackDecoderTest, EncoderStreamErrorTooLargeInteger) {
EXPECT_CALL(encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Encoded integer too large.")));
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Encoded integer too large.")));
- DecodeEncoderStreamData(
- quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fffffffffffffffffffff"));
}
TEST_P(QpackDecoderTest, InvalidDynamicEntryWhenBaseIsZero) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index.")));
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0280" // Required Insert Count is 1. Base 1 - 1 - 0 = 0 is explicitly
// permitted by the spec.
"80")); // However, addressing entry with relative index 0 would point to
@@ -511,18 +530,18 @@ TEST_P(QpackDecoderTest, InvalidNegativeBase) {
// Required Insert Count 1, Delta Base 1 with sign bit set, Base would
// be 1 - 1 - 1 = -1, but it is not allowed to be negative.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0281"));
+ DecodeHeaderBlock(absl::HexStringToBytes("0281"));
}
TEST_P(QpackDecoderTest, InvalidDynamicEntryByRelativeIndex) {
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"81")); // Indexed Header Field instruction addressing relative index 1.
@@ -530,7 +549,7 @@ TEST_P(QpackDecoderTest, InvalidDynamicEntryByRelativeIndex) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"4100")); // Literal Header Field with Name Reference instruction
@@ -540,18 +559,18 @@ TEST_P(QpackDecoderTest, InvalidDynamicEntryByRelativeIndex) {
TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) {
// Update dynamic table capacity to 128.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3f61"));
// Add literal entry with name "foo" and value "bar", size 32 + 3 + 3 = 38.
// This fits in the table three times.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
// Duplicate entry four times. This evicts the first two instances.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00000000"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("00000000"));
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Dynamic table entry already evicted.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0500" // Required Insert Count 4 and Delta Base 0.
// Base is 4 + 0 = 4.
"82")); // Indexed Header Field instruction addressing relative index 2.
@@ -560,7 +579,7 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Dynamic table entry already evicted.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0500" // Required Insert Count 4 and Delta Base 0.
// Base is 4 + 0 = 4.
"4200")); // Literal Header Field with Name Reference instruction
@@ -570,7 +589,7 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Dynamic table entry already evicted.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0380" // Required Insert Count 2 and Delta Base 0 with sign bit set.
// Base is 2 - 0 - 1 = 1
"10")); // Indexed Header Field instruction addressing dynamic table
@@ -580,7 +599,7 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Dynamic table entry already evicted.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0380" // Required Insert Count 2 and Delta Base 0 with sign bit set.
// Base is 2 - 0 - 1 = 1
"0000")); // Literal Header Field With Name Reference instruction
@@ -589,17 +608,20 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) {
}
TEST_P(QpackDecoderTest, TableCapacityMustNotExceedMaximum) {
- EXPECT_CALL(
- encoder_stream_error_delegate_,
- OnEncoderStreamError(Eq("Error updating dynamic table capacity.")));
+ EXPECT_CALL(encoder_stream_error_delegate_,
+ OnEncoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_ENCODER_STREAM_SET_DYNAMIC_TABLE_CAPACITY
+ : QUIC_QPACK_ENCODER_STREAM_ERROR,
+ Eq("Error updating dynamic table capacity.")));
// Try to update dynamic table capacity to 2048, which exceeds the maximum.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe10f"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe10f"));
}
TEST_P(QpackDecoderTest, SetDynamicTableCapacity) {
// Update dynamic table capacity to 128, which does not exceed the maximum.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3f61"));
}
TEST_P(QpackDecoderTest, InvalidEncodedRequiredInsertCount) {
@@ -609,7 +631,7 @@ TEST_P(QpackDecoderTest, InvalidEncodedRequiredInsertCount) {
// A value of 1 cannot be encoded as 65 even though it has the same remainder.
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Error decoding Required Insert Count.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("4100"));
+ DecodeHeaderBlock(absl::HexStringToBytes("4100"));
}
// Regression test for https://crbug.com/970218: Decoder must stop processing
@@ -618,7 +640,7 @@ TEST_P(QpackDecoderTest, DataAfterInvalidEncodedRequiredInsertCount) {
EXPECT_CALL(handler_, OnDecodingErrorDetected(
Eq("Error decoding Required Insert Count.")));
// Header Block Prefix followed by some extra data.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("410000"));
+ DecodeHeaderBlock(absl::HexStringToBytes("410000"));
}
TEST_P(QpackDecoderTest, WrappedRequiredInsertCount) {
@@ -626,12 +648,12 @@ TEST_P(QpackDecoderTest, WrappedRequiredInsertCount) {
// MaxEntries is 1024 / 32 = 32.
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and a 600 byte long value. This will fit
// in the dynamic table once but not twice.
DecodeEncoderStreamData(
- quiche::QuicheTextUtils::HexDecode("6294e7" // Name "foo".
- "7fd903")); // Value length 600.
+ absl::HexStringToBytes("6294e7" // Name "foo".
+ "7fd903")); // Value length 600.
std::string header_value(600, 'Z');
DecodeEncoderStreamData(header_value);
@@ -646,7 +668,7 @@ TEST_P(QpackDecoderTest, WrappedRequiredInsertCount) {
WriteStreamData(Eq(kHeaderAcknowledgement)));
// Send header block with Required Insert Count = 201.
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0a00" // Encoded Required Insert Count 10, Required Insert Count 201,
// Delta Base 0, Base 201.
"80")); // Emit dynamic table entry with relative index 0.
@@ -654,31 +676,31 @@ TEST_P(QpackDecoderTest, WrappedRequiredInsertCount) {
TEST_P(QpackDecoderTest, NonZeroRequiredInsertCountButNoDynamicEntries) {
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("GET")));
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Required Insert Count too large.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count is 1.
"d1")); // But the only instruction references the static table.
}
TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) {
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
EXPECT_CALL(
handler_,
OnDecodingErrorDetected(
Eq("Absolute Index must be smaller than Required Insert Count.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0201" // Required Insert Count 1 and Delta Base 1.
// Base is 1 + 1 = 2.
"80")); // Indexed Header Field instruction addressing dynamic table
@@ -690,7 +712,7 @@ TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) {
OnDecodingErrorDetected(
Eq("Absolute Index must be smaller than Required Insert Count.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0201" // Required Insert Count 1 and Delta Base 1.
// Base is 1 + 1 = 2.
"4000")); // Literal Header Field with Name Reference instruction
@@ -703,7 +725,7 @@ TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) {
OnDecodingErrorDetected(
Eq("Absolute Index must be smaller than Required Insert Count.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"10")); // Indexed Header Field with Post-Base Index instruction
@@ -716,7 +738,7 @@ TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) {
OnDecodingErrorDetected(
Eq("Absolute Index must be smaller than Required Insert Count.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"0000")); // Literal Header Field with Post-Base Name Reference
@@ -727,19 +749,19 @@ TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) {
TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) {
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
// Duplicate entry twice so that decoding of header blocks with Required
// Insert Count not exceeding 3 is not blocked.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00"));
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("00"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("00"));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Required Insert Count too large.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0300" // Required Insert Count 2 and Delta Base 0.
// Base is 2 + 0 = 2.
"81")); // Indexed Header Field instruction addressing dynamic table
@@ -751,7 +773,7 @@ TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Required Insert Count too large.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0300" // Required Insert Count 2 and Delta Base 0.
// Base is 2 + 0 = 2.
"4100")); // Literal Header Field with Name Reference instruction
@@ -763,7 +785,7 @@ TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Required Insert Count too large.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0481" // Required Insert Count 3 and Delta Base 1 with sign bit set.
// Base is 3 - 1 - 1 = 1.
"10")); // Indexed Header Field with Post-Base Index instruction
@@ -775,7 +797,7 @@ TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) {
EXPECT_CALL(handler_,
OnDecodingErrorDetected(Eq("Required Insert Count too large.")));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0481" // Required Insert Count 3 and Delta Base 1 with sign bit set.
// Base is 3 - 1 - 1 = 1.
"0000")); // Literal Header Field with Post-Base Name Reference
@@ -785,7 +807,7 @@ TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) {
}
TEST_P(QpackDecoderTest, BlockedDecoding) {
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80")); // Indexed Header Field instruction addressing dynamic table
@@ -797,14 +819,14 @@ TEST_P(QpackDecoderTest, BlockedDecoding) {
WriteStreamData(Eq(kHeaderAcknowledgement)));
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
}
TEST_P(QpackDecoderTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) {
StartDecoding();
- DecodeData(quiche::QuicheTextUtils::HexDecode(
+ DecodeData(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80" // Indexed Header Field instruction addressing dynamic table
@@ -812,7 +834,7 @@ TEST_P(QpackDecoderTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) {
"d1")); // Static table entry with index 17.
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar". Decoding is now
// unblocked because dynamic table Insert Count reached the Required Insert
@@ -820,14 +842,14 @@ TEST_P(QpackDecoderTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) {
// the already consumed part of the header block.
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("GET")));
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
Mock::VerifyAndClearExpectations(&handler_);
// Rest of header block is processed by QpackProgressiveDecoder
// in the unblocked state.
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":scheme"), Eq("https")));
- DecodeData(quiche::QuicheTextUtils::HexDecode(
+ DecodeData(absl::HexStringToBytes(
"80" // Indexed Header Field instruction addressing dynamic table
// entry with relative index 0, absolute index 0.
"d7")); // Static table entry with index 23.
@@ -843,7 +865,7 @@ TEST_P(QpackDecoderTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) {
TEST_P(QpackDecoderTest,
BlockedDecodingUnblockedAndErrorBeforeEndOfHeaderBlock) {
StartDecoding();
- DecodeData(quiche::QuicheTextUtils::HexDecode(
+ DecodeData(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80" // Indexed Header Field instruction addressing dynamic table
@@ -851,7 +873,7 @@ TEST_P(QpackDecoderTest,
"81")); // Relative index 1 is equal to Base, therefore invalid.
// Set dynamic table capacity to 1024.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3fe107"));
// Add literal entry with name "foo" and value "bar". Decoding is now
// unblocked because dynamic table Insert Count reached the Required Insert
@@ -859,7 +881,7 @@ TEST_P(QpackDecoderTest,
// the already consumed part of the header block.
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar")));
EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index.")));
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
}
// Make sure that Required Insert Count is compared to Insert Count,
@@ -867,19 +889,19 @@ TEST_P(QpackDecoderTest,
TEST_P(QpackDecoderTest, BlockedDecodingAndEvictedEntries) {
// Update dynamic table capacity to 128.
// At most three non-empty entries fit in the dynamic table.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("3f61"));
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0700" // Required Insert Count 6 and Delta Base 0.
// Base is 6 + 0 = 6.
"80")); // Indexed Header Field instruction addressing dynamic table
// entry with relative index 0, absolute index 5.
// Add literal entry with name "foo" and value "bar".
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e703626172"));
// Duplicate entry four times. This evicts the first two instances.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00000000"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("00000000"));
EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("baz")));
EXPECT_CALL(handler_, OnDecodingCompleted());
@@ -888,13 +910,13 @@ TEST_P(QpackDecoderTest, BlockedDecodingAndEvictedEntries) {
// Add literal entry with name "foo" and value "bar".
// Insert Count is now 6, reaching Required Insert Count of the header block.
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e70362617a"));
+ DecodeEncoderStreamData(absl::HexStringToBytes("6294e70362617a"));
}
TEST_P(QpackDecoderTest, TooManyBlockedStreams) {
// Required Insert Count 1 and Delta Base 0.
// Without any dynamic table entries received, decoding is blocked.
- std::string data = quiche::QuicheTextUtils::HexDecode("0200");
+ std::string data = absl::HexStringToBytes("0200");
auto progressive_decoder1 = CreateProgressiveDecoder(/* stream_id = */ 1);
progressive_decoder1->Decode(data);
@@ -907,7 +929,7 @@ TEST_P(QpackDecoderTest, TooManyBlockedStreams) {
}
TEST_P(QpackDecoderTest, InsertCountIncrement) {
- DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode(
+ DecodeEncoderStreamData(absl::HexStringToBytes(
"3fe107" // Set dynamic table capacity to 1024.
"6294e703626172" // Add literal entry with name "foo" and value "bar".
"00")); // Duplicate entry.
@@ -919,11 +941,11 @@ TEST_P(QpackDecoderTest, InsertCountIncrement) {
// Known Insert Count to one. Decoder should send an Insert Count Increment
// instruction with increment of one to update Known Insert Count to two.
EXPECT_CALL(decoder_stream_sender_delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode(
+ WriteStreamData(Eq(absl::HexStringToBytes(
"81" // Header Acknowledgement on stream 1
"01")))); // Insert Count Increment with increment of one
- DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode(
+ DecodeHeaderBlock(absl::HexStringToBytes(
"0200" // Required Insert Count 1 and Delta Base 0.
// Base is 1 + 0 = 1.
"80")); // Dynamic table entry with relative index 0, absolute index 0.
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc
index 67adf1268eb..bf7cdc63a3f 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc
@@ -7,13 +7,14 @@
#include <algorithm>
#include <utility>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h"
#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -58,7 +59,7 @@ QpackInstructionWithValues
QpackEncoder::EncodeLiteralHeaderFieldWithNameReference(
bool is_static,
uint64_t index,
- quiche::QuicheStringPiece value,
+ absl::string_view value,
QpackBlockingManager::IndexSet* referred_indices) {
// Add |index| to |*referred_indices| only if entry is in the dynamic table.
if (!is_static) {
@@ -70,14 +71,14 @@ QpackEncoder::EncodeLiteralHeaderFieldWithNameReference(
// static
QpackInstructionWithValues QpackEncoder::EncodeLiteralHeaderField(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ absl::string_view name,
+ absl::string_view value) {
return QpackInstructionWithValues::LiteralHeaderField(name, value);
}
QpackEncoder::Instructions QpackEncoder::FirstPassEncode(
QuicStreamId stream_id,
- const spdy::SpdyHeaderBlock& header_list,
+ const spdy::Http2HeaderBlock& header_list,
QpackBlockingManager::IndexSet* referred_indices,
QuicByteCount* encoder_stream_sent_byte_count) {
// If previous instructions are buffered in |encoder_stream_sender_|,
@@ -110,8 +111,8 @@ QpackEncoder::Instructions QpackEncoder::FirstPassEncode(
for (const auto& header : ValueSplittingHeaderList(&header_list)) {
// These strings are owned by |header_list|.
- quiche::QuicheStringPiece name = header.first;
- quiche::QuicheStringPiece value = header.second;
+ absl::string_view name = header.first;
+ absl::string_view value = header.second;
bool is_static;
uint64_t index;
@@ -355,7 +356,7 @@ std::string QpackEncoder::SecondPassEncode(
std::string QpackEncoder::EncodeHeaderList(
QuicStreamId stream_id,
- const spdy::SpdyHeaderBlock& header_list,
+ const spdy::Http2HeaderBlock& header_list,
QuicByteCount* encoder_stream_sent_byte_count) {
// Keep track of all dynamic table indices that this header block refers to so
// that it can be passed to QpackBlockingManager.
@@ -403,29 +404,32 @@ bool QpackEncoder::SetMaximumBlockedStreams(uint64_t maximum_blocked_streams) {
void QpackEncoder::OnInsertCountIncrement(uint64_t increment) {
if (increment == 0) {
- decoder_stream_error_delegate_->OnDecoderStreamError(
- "Invalid increment value 0.");
+ OnErrorDetected(QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT,
+ "Invalid increment value 0.");
return;
}
if (!blocking_manager_.OnInsertCountIncrement(increment)) {
- decoder_stream_error_delegate_->OnDecoderStreamError(
- "Insert Count Increment instruction causes overflow.");
+ OnErrorDetected(QUIC_QPACK_DECODER_STREAM_INCREMENT_OVERFLOW,
+ "Insert Count Increment instruction causes overflow.");
}
if (blocking_manager_.known_received_count() >
header_table_.inserted_entry_count()) {
- decoder_stream_error_delegate_->OnDecoderStreamError(quiche::QuicheStrCat(
- "Increment value ", increment, " raises known received count to ",
- blocking_manager_.known_received_count(),
- " exceeding inserted entry count ",
- header_table_.inserted_entry_count()));
+ OnErrorDetected(
+ QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT,
+ quiche::QuicheStrCat("Increment value ", increment,
+ " raises known received count to ",
+ blocking_manager_.known_received_count(),
+ " exceeding inserted entry count ",
+ header_table_.inserted_entry_count()));
}
}
void QpackEncoder::OnHeaderAcknowledgement(QuicStreamId stream_id) {
if (!blocking_manager_.OnHeaderAcknowledgement(stream_id)) {
- decoder_stream_error_delegate_->OnDecoderStreamError(
+ OnErrorDetected(
+ QUIC_QPACK_DECODER_STREAM_INCORRECT_ACKNOWLEDGEMENT,
quiche::QuicheStrCat("Header Acknowledgement received for stream ",
stream_id, " with no outstanding header blocks."));
}
@@ -435,8 +439,16 @@ void QpackEncoder::OnStreamCancellation(QuicStreamId stream_id) {
blocking_manager_.OnStreamCancellation(stream_id);
}
-void QpackEncoder::OnErrorDetected(quiche::QuicheStringPiece error_message) {
- decoder_stream_error_delegate_->OnDecoderStreamError(error_message);
+void QpackEncoder::OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) {
+ if (GetQuicReloadableFlag(quic_granular_qpack_error_codes)) {
+ QUIC_CODE_COUNT_N(quic_granular_qpack_error_codes, 1, 2);
+ decoder_stream_error_delegate_->OnDecoderStreamError(error_code,
+ error_message);
+ } else {
+ decoder_stream_error_delegate_->OnDecoderStreamError(
+ QUIC_QPACK_DECODER_STREAM_ERROR, error_message);
+ }
}
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h
index 202fc6d8ef1..c6c8aa5d8ae 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h
@@ -10,21 +10,17 @@
#include <string>
#include <vector>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
+#include "net/third_party/quiche/src/quic/core/quic_error_codes.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
-
-namespace spdy {
-
-class SpdyHeaderBlock;
-
-} // namespace spdy
+#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
namespace quic {
@@ -45,8 +41,8 @@ class QUIC_EXPORT_PRIVATE QpackEncoder
public:
virtual ~DecoderStreamErrorDelegate() {}
- virtual void OnDecoderStreamError(
- quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnDecoderStreamError(QuicErrorCode error_code,
+ absl::string_view error_message) = 0;
};
QpackEncoder(DecoderStreamErrorDelegate* decoder_stream_error_delegate);
@@ -56,7 +52,7 @@ class QUIC_EXPORT_PRIVATE QpackEncoder
// |*encoder_stream_sent_byte_count| will be set to the number of bytes sent
// on the encoder stream to insert dynamic table entries.
std::string EncodeHeaderList(QuicStreamId stream_id,
- const spdy::SpdyHeaderBlock& header_list,
+ const spdy::Http2HeaderBlock& header_list,
QuicByteCount* encoder_stream_sent_byte_count);
// Set maximum dynamic table capacity to |maximum_dynamic_table_capacity|,
@@ -83,7 +79,8 @@ class QUIC_EXPORT_PRIVATE QpackEncoder
void OnInsertCountIncrement(uint64_t increment) override;
void OnHeaderAcknowledgement(QuicStreamId stream_id) override;
void OnStreamCancellation(QuicStreamId stream_id) override;
- void OnErrorDetected(quiche::QuicheStringPiece error_message) override;
+ void OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) override;
// delegate must be set if dynamic table capacity is not zero.
void set_qpack_stream_sender_delegate(QpackStreamSenderDelegate* delegate) {
@@ -122,13 +119,13 @@ class QUIC_EXPORT_PRIVATE QpackEncoder
static QpackInstructionWithValues EncodeLiteralHeaderFieldWithNameReference(
bool is_static,
uint64_t index,
- quiche::QuicheStringPiece value,
+ absl::string_view value,
QpackBlockingManager::IndexSet* referred_indices);
// Generate literal header field instruction.
static QpackInstructionWithValues EncodeLiteralHeaderField(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ absl::string_view name,
+ absl::string_view value);
// Performs first pass of two-pass encoding: represent each header field in
// |*header_list| as a reference to an existing entry, the name of an existing
@@ -140,9 +137,9 @@ class QUIC_EXPORT_PRIVATE QpackEncoder
// encoder stream to insert dynamic table entries. Returns list of header
// field representations, with all dynamic table entries referred to with
// absolute indices. Returned Instructions object may have
- // quiche::QuicheStringPieces pointing to strings owned by |*header_list|.
+ // absl::string_views pointing to strings owned by |*header_list|.
Instructions FirstPassEncode(QuicStreamId stream_id,
- const spdy::SpdyHeaderBlock& header_list,
+ const spdy::Http2HeaderBlock& header_list,
QpackBlockingManager::IndexSet* referred_indices,
QuicByteCount* encoder_stream_sent_byte_count);
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc
index 56ee23241db..95260ab3e7a 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc
@@ -4,10 +4,10 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/http2/decoder/decode_buffer.h"
#include "net/third_party/quiche/src/http2/decoder/decode_status.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -18,7 +18,7 @@ QpackEncoderStreamReceiver::QpackEncoderStreamReceiver(Delegate* delegate)
DCHECK(delegate_);
}
-void QpackEncoderStreamReceiver::Decode(quiche::QuicheStringPiece data) {
+void QpackEncoderStreamReceiver::Decode(absl::string_view data) {
if (data.empty() || error_detected_) {
return;
}
@@ -51,12 +51,29 @@ bool QpackEncoderStreamReceiver::OnInstructionDecoded(
return true;
}
-void QpackEncoderStreamReceiver::OnError(
- quiche::QuicheStringPiece error_message) {
+void QpackEncoderStreamReceiver::OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message) {
DCHECK(!error_detected_);
error_detected_ = true;
- delegate_->OnErrorDetected(error_message);
+
+ QuicErrorCode quic_error_code;
+ switch (error_code) {
+ case QpackInstructionDecoder::ErrorCode::INTEGER_TOO_LARGE:
+ quic_error_code = QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE;
+ break;
+ case QpackInstructionDecoder::ErrorCode::STRING_LITERAL_TOO_LONG:
+ quic_error_code = QUIC_QPACK_ENCODER_STREAM_STRING_LITERAL_TOO_LONG;
+ break;
+ case QpackInstructionDecoder::ErrorCode::HUFFMAN_ENCODING_ERROR:
+ quic_error_code = QUIC_QPACK_ENCODER_STREAM_HUFFMAN_ENCODING_ERROR;
+ break;
+ default:
+ quic_error_code = QUIC_INTERNAL_ERROR;
+ }
+
+ delegate_->OnErrorDetected(quic_error_code, error_message);
}
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h
index 80622e5460d..fa94a5353ee 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h
@@ -8,10 +8,11 @@
#include <cstdint>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h"
+#include "net/third_party/quiche/src/quic/core/quic_error_codes.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -29,17 +30,17 @@ class QUIC_EXPORT_PRIVATE QpackEncoderStreamReceiver
// 5.2.1. Insert With Name Reference
virtual void OnInsertWithNameReference(bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value) = 0;
+ absl::string_view value) = 0;
// 5.2.2. Insert Without Name Reference
- virtual void OnInsertWithoutNameReference(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) = 0;
+ virtual void OnInsertWithoutNameReference(absl::string_view name,
+ absl::string_view value) = 0;
// 5.2.3. Duplicate
virtual void OnDuplicate(uint64_t index) = 0;
// 5.2.4. Set Dynamic Table Capacity
virtual void OnSetDynamicTableCapacity(uint64_t capacity) = 0;
// Decoding error
- virtual void OnErrorDetected(quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnErrorDetected(QuicErrorCode error_code,
+ absl::string_view error_message) = 0;
};
explicit QpackEncoderStreamReceiver(Delegate* delegate);
@@ -53,11 +54,12 @@ class QUIC_EXPORT_PRIVATE QpackEncoderStreamReceiver
// Decode data and call appropriate Delegate method after each decoded
// instruction. Once an error occurs, Delegate::OnErrorDetected() is called,
// and all further data is ignored.
- void Decode(quiche::QuicheStringPiece data) override;
+ void Decode(absl::string_view data) override;
// QpackInstructionDecoder::Delegate implementation.
bool OnInstructionDecoded(const QpackInstruction* instruction) override;
- void OnError(quiche::QuicheStringPiece error_message) override;
+ void OnInstructionDecodingError(QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message) override;
private:
QpackInstructionDecoder instruction_decoder_;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc
index 71b6d3438e4..31bea896899 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc
@@ -4,8 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h"
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
using testing::Eq;
@@ -21,19 +22,17 @@ class MockDelegate : public QpackEncoderStreamReceiver::Delegate {
MOCK_METHOD(void,
OnInsertWithNameReference,
- (bool is_static,
- uint64_t name_index,
- quiche::QuicheStringPiece value),
+ (bool is_static, uint64_t name_index, absl::string_view value),
(override));
MOCK_METHOD(void,
OnInsertWithoutNameReference,
- (quiche::QuicheStringPiece name, quiche::QuicheStringPiece value),
+ (absl::string_view name, absl::string_view value),
(override));
MOCK_METHOD(void, OnDuplicate, (uint64_t index), (override));
MOCK_METHOD(void, OnSetDynamicTableCapacity, (uint64_t capacity), (override));
MOCK_METHOD(void,
OnErrorDetected,
- (quiche::QuicheStringPiece error_message),
+ (QuicErrorCode error_code, absl::string_view error_message),
(override));
};
@@ -42,7 +41,7 @@ class QpackEncoderStreamReceiverTest : public QuicTest {
QpackEncoderStreamReceiverTest() : stream_(&delegate_) {}
~QpackEncoderStreamReceiverTest() override = default;
- void Decode(quiche::QuicheStringPiece data) { stream_.Decode(data); }
+ void Decode(absl::string_view data) { stream_.Decode(data); }
StrictMock<MockDelegate>* delegate() { return &delegate_; }
private:
@@ -62,7 +61,7 @@ TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReference) {
EXPECT_CALL(*delegate(),
OnInsertWithNameReference(false, 42, Eq(std::string(127, 'Z'))));
- Decode(quiche::QuicheTextUtils::HexDecode(
+ Decode(absl::HexStringToBytes(
"c500"
"c28294e7"
"bf4a03626172"
@@ -73,15 +72,19 @@ TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReference) {
}
TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReferenceIndexTooLarge) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
- Decode(quiche::QuicheTextUtils::HexDecode("bfffffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("bfffffffffffffffffffffff"));
}
TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReferenceValueTooLong) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
- Decode(quiche::QuicheTextUtils::HexDecode("c57fffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("c57fffffffffffffffffffff"));
}
TEST_F(QpackEncoderStreamReceiverTest, InsertWithoutNameReference) {
@@ -97,7 +100,7 @@ TEST_F(QpackEncoderStreamReceiverTest, InsertWithoutNameReference) {
OnInsertWithoutNameReference(Eq(std::string(31, 'Z')),
Eq(std::string(127, 'Z'))));
- Decode(quiche::QuicheTextUtils::HexDecode(
+ Decode(absl::HexStringToBytes(
"4000"
"4362617203626172"
"6294e78294e7"
@@ -111,33 +114,41 @@ TEST_F(QpackEncoderStreamReceiverTest, InsertWithoutNameReference) {
// Name Length value is too large for varint decoder to decode.
TEST_F(QpackEncoderStreamReceiverTest,
InsertWithoutNameReferenceNameTooLongForVarintDecoder) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
- Decode(quiche::QuicheTextUtils::HexDecode("5fffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("5fffffffffffffffffffff"));
}
// Name Length value can be decoded by varint decoder but exceeds 1 MB limit.
TEST_F(QpackEncoderStreamReceiverTest,
InsertWithoutNameReferenceNameExceedsLimit) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("String literal too long.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_STRING_LITERAL_TOO_LONG,
+ Eq("String literal too long.")));
- Decode(quiche::QuicheTextUtils::HexDecode("5fffff7f"));
+ Decode(absl::HexStringToBytes("5fffff7f"));
}
// Value Length value is too large for varint decoder to decode.
TEST_F(QpackEncoderStreamReceiverTest,
InsertWithoutNameReferenceValueTooLongForVarintDecoder) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
- Decode(quiche::QuicheTextUtils::HexDecode("436261727fffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("436261727fffffffffffffffffffff"));
}
// Value Length value can be decoded by varint decoder but exceeds 1 MB limit.
TEST_F(QpackEncoderStreamReceiverTest,
InsertWithoutNameReferenceValueExceedsLimit) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("String literal too long.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_STRING_LITERAL_TOO_LONG,
+ Eq("String literal too long.")));
- Decode(quiche::QuicheTextUtils::HexDecode("436261727fffff7f"));
+ Decode(absl::HexStringToBytes("436261727fffff7f"));
}
TEST_F(QpackEncoderStreamReceiverTest, Duplicate) {
@@ -146,13 +157,15 @@ TEST_F(QpackEncoderStreamReceiverTest, Duplicate) {
// Large index requires two extension bytes.
EXPECT_CALL(*delegate(), OnDuplicate(500));
- Decode(quiche::QuicheTextUtils::HexDecode("111fd503"));
+ Decode(absl::HexStringToBytes("111fd503"));
}
TEST_F(QpackEncoderStreamReceiverTest, DuplicateIndexTooLarge) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
- Decode(quiche::QuicheTextUtils::HexDecode("1fffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("1fffffffffffffffffffff"));
}
TEST_F(QpackEncoderStreamReceiverTest, SetDynamicTableCapacity) {
@@ -161,13 +174,23 @@ TEST_F(QpackEncoderStreamReceiverTest, SetDynamicTableCapacity) {
// Large capacity requires two extension bytes.
EXPECT_CALL(*delegate(), OnSetDynamicTableCapacity(500));
- Decode(quiche::QuicheTextUtils::HexDecode("313fd503"));
+ Decode(absl::HexStringToBytes("313fd503"));
}
TEST_F(QpackEncoderStreamReceiverTest, SetDynamicTableCapacityTooLarge) {
- EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large.")));
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
+
+ Decode(absl::HexStringToBytes("3fffffffffffffffffffff"));
+}
+
+TEST_F(QpackEncoderStreamReceiverTest, InvalidHuffmanEncoding) {
+ EXPECT_CALL(*delegate(),
+ OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_HUFFMAN_ENCODING_ERROR,
+ Eq("Error in Huffman-encoded string.")));
- Decode(quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff"));
+ Decode(absl::HexStringToBytes("c281ff"));
}
} // namespace
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc
index 0ae1aae7ff1..88214abee17 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc
@@ -8,9 +8,9 @@
#include <limits>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -19,7 +19,7 @@ QpackEncoderStreamSender::QpackEncoderStreamSender() : delegate_(nullptr) {}
void QpackEncoderStreamSender::SendInsertWithNameReference(
bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value) {
+ absl::string_view value) {
instruction_encoder_.Encode(
QpackInstructionWithValues::InsertWithNameReference(is_static, name_index,
value),
@@ -27,8 +27,8 @@ void QpackEncoderStreamSender::SendInsertWithNameReference(
}
void QpackEncoderStreamSender::SendInsertWithoutNameReference(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ absl::string_view name,
+ absl::string_view value) {
instruction_encoder_.Encode(
QpackInstructionWithValues::InsertWithoutNameReference(name, value),
&buffer_);
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h
index dee23c50d5b..dbef027e1b7 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h
@@ -7,11 +7,11 @@
#include <cstdint>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -29,10 +29,10 @@ class QUIC_EXPORT_PRIVATE QpackEncoderStreamSender {
// 5.2.1. Insert With Name Reference
void SendInsertWithNameReference(bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value);
+ absl::string_view value);
// 5.2.2. Insert Without Name Reference
- void SendInsertWithoutNameReference(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ void SendInsertWithoutNameReference(absl::string_view name,
+ absl::string_view value);
// 5.2.3. Duplicate
void SendDuplicate(uint64_t index);
// 5.2.4. Set Dynamic Table Capacity
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc
index ea45acc1abd..08138190c84 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc
@@ -4,6 +4,7 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h"
+#include "absl/strings/escaping.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
@@ -30,22 +31,21 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithNameReference) {
EXPECT_EQ(0u, stream_.BufferedByteCount());
// Static, index fits in prefix, empty value.
- std::string expected_encoded_data =
- quiche::QuicheTextUtils::HexDecode("c500");
+ std::string expected_encoded_data = absl::HexStringToBytes("c500");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithNameReference(true, 5, "");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
stream_.Flush();
// Static, index fits in prefix, Huffman encoded value.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode("c28294e7");
+ expected_encoded_data = absl::HexStringToBytes("c28294e7");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithNameReference(true, 2, "foo");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
stream_.Flush();
// Not static, index does not fit in prefix, not Huffman encoded value.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode("bf4a03626172");
+ expected_encoded_data = absl::HexStringToBytes("bf4a03626172");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithNameReference(false, 137, "bar");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
@@ -53,7 +53,7 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithNameReference) {
// Value length does not fit in prefix.
// 'Z' would be Huffman encoded to 8 bits, so no Huffman encoding is used.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode(
+ expected_encoded_data = absl::HexStringToBytes(
"aa7f005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
"5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
"5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
@@ -68,23 +68,21 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithoutNameReference) {
EXPECT_EQ(0u, stream_.BufferedByteCount());
// Empty name and value.
- std::string expected_encoded_data =
- quiche::QuicheTextUtils::HexDecode("4000");
+ std::string expected_encoded_data = absl::HexStringToBytes("4000");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithoutNameReference("", "");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
stream_.Flush();
// Huffman encoded short strings.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode("6294e78294e7");
+ expected_encoded_data = absl::HexStringToBytes("6294e78294e7");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithoutNameReference("foo", "foo");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
stream_.Flush();
// Not Huffman encoded short strings.
- expected_encoded_data =
- quiche::QuicheTextUtils::HexDecode("4362617203626172");
+ expected_encoded_data = absl::HexStringToBytes("4362617203626172");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendInsertWithoutNameReference("bar", "bar");
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
@@ -92,7 +90,7 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithoutNameReference) {
// Not Huffman encoded long strings; length does not fit on prefix.
// 'Z' would be Huffman encoded to 8 bits, so no Huffman encoding is used.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode(
+ expected_encoded_data = absl::HexStringToBytes(
"5f005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a7f"
"005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
"5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
@@ -109,14 +107,14 @@ TEST_F(QpackEncoderStreamSenderTest, Duplicate) {
EXPECT_EQ(0u, stream_.BufferedByteCount());
// Small index fits in prefix.
- std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode("11");
+ std::string expected_encoded_data = absl::HexStringToBytes("11");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendDuplicate(17);
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
stream_.Flush();
// Large index requires two extension bytes.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode("1fd503");
+ expected_encoded_data = absl::HexStringToBytes("1fd503");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendDuplicate(500);
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
@@ -127,7 +125,7 @@ TEST_F(QpackEncoderStreamSenderTest, SetDynamicTableCapacity) {
EXPECT_EQ(0u, stream_.BufferedByteCount());
// Small capacity fits in prefix.
- std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode("31");
+ std::string expected_encoded_data = absl::HexStringToBytes("31");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendSetDynamicTableCapacity(17);
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
@@ -135,7 +133,7 @@ TEST_F(QpackEncoderStreamSenderTest, SetDynamicTableCapacity) {
EXPECT_EQ(0u, stream_.BufferedByteCount());
// Large capacity requires two extension bytes.
- expected_encoded_data = quiche::QuicheTextUtils::HexDecode("3fd503");
+ expected_encoded_data = absl::HexStringToBytes("3fd503");
EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data)));
stream_.SendSetDynamicTableCapacity(500);
EXPECT_EQ(expected_encoded_data.size(), stream_.BufferedByteCount());
@@ -157,7 +155,7 @@ TEST_F(QpackEncoderStreamSenderTest, Coalesce) {
// Duplicate entry.
stream_.SendDuplicate(17);
- std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode(
+ std::string expected_encoded_data = absl::HexStringToBytes(
"c500" // Insert entry with static name reference.
"c28294e7" // Insert entry with static name reference.
"6294e78294e7" // Insert literal entry.
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc
index e0d21c53269..08c6123fc82 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc
@@ -7,13 +7,15 @@
#include <limits>
#include <string>
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
using ::testing::_;
@@ -35,7 +37,7 @@ class QpackEncoderTest : public QuicTest {
~QpackEncoderTest() override = default;
- std::string Encode(const spdy::SpdyHeaderBlock& header_list) {
+ std::string Encode(const spdy::Http2HeaderBlock& header_list) {
return encoder_.EncodeHeaderList(/* stream_id = */ 1, header_list,
&encoder_stream_sent_byte_count_);
}
@@ -47,53 +49,53 @@ class QpackEncoderTest : public QuicTest {
};
TEST_F(QpackEncoderTest, Empty) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000"), output);
+ EXPECT_EQ(absl::HexStringToBytes("0000"), output);
}
TEST_F(QpackEncoderTest, EmptyName) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[""] = "foo";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000208294e7"), output);
+ EXPECT_EQ(absl::HexStringToBytes("0000208294e7"), output);
}
TEST_F(QpackEncoderTest, EmptyValue) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002a94e700"), output);
+ EXPECT_EQ(absl::HexStringToBytes("00002a94e700"), output);
}
TEST_F(QpackEncoderTest, EmptyNameAndValue) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[""] = "";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002000"), output);
+ EXPECT_EQ(absl::HexStringToBytes("00002000"), output);
}
TEST_F(QpackEncoderTest, Simple) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002a94e703626172"), output);
+ EXPECT_EQ(absl::HexStringToBytes("00002a94e703626172"), output);
}
TEST_F(QpackEncoderTest, Multiple) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
// 'Z' would be Huffman encoded to 8 bits, so no Huffman encoding is used.
header_list["ZZZZZZZ"] = std::string(127, 'Z');
std::string output = Encode(header_list);
EXPECT_EQ(
- quiche::QuicheTextUtils::HexDecode(
+ absl::HexStringToBytes(
"0000" // prefix
"2a94e703626172" // foo: bar
"27005a5a5a5a5a5a5a" // 7 octet long header name, the smallest number
@@ -109,63 +111,69 @@ TEST_F(QpackEncoderTest, Multiple) {
TEST_F(QpackEncoderTest, StaticTable) {
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "GET";
header_list["accept-encoding"] = "gzip, deflate, br";
header_list["location"] = "";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000d1dfcc"), output);
+ EXPECT_EQ(absl::HexStringToBytes("0000d1dfcc"), output);
}
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "POST";
header_list["accept-encoding"] = "compress";
header_list["location"] = "foo";
std::string output = Encode(header_list);
- EXPECT_EQ(
- quiche::QuicheTextUtils::HexDecode("0000d45f108621e9aec2a11f5c8294e7"),
- output);
+ EXPECT_EQ(absl::HexStringToBytes("0000d45f108621e9aec2a11f5c8294e7"),
+ output);
}
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "TRACE";
header_list["accept-encoding"] = "";
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00005f000554524143455f1000"),
- output);
+ EXPECT_EQ(absl::HexStringToBytes("00005f000554524143455f1000"), output);
}
}
TEST_F(QpackEncoderTest, DecoderStreamError) {
EXPECT_CALL(decoder_stream_error_delegate_,
- OnDecoderStreamError(Eq("Encoded integer too large.")));
+ OnDecoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE
+ : QUIC_QPACK_DECODER_STREAM_ERROR,
+ Eq("Encoded integer too large.")));
QpackEncoder encoder(&decoder_stream_error_delegate_);
encoder.set_qpack_stream_sender_delegate(&encoder_stream_sender_delegate_);
encoder.decoder_stream_receiver()->Decode(
- quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff"));
+ absl::HexStringToBytes("ffffffffffffffffffffff"));
}
TEST_F(QpackEncoderTest, SplitAlongNullCharacter) {
- spdy::SpdyHeaderBlock header_list;
- header_list["foo"] = quiche::QuicheStringPiece("bar\0bar\0baz", 11);
+ spdy::Http2HeaderBlock header_list;
+ header_list["foo"] = absl::string_view("bar\0bar\0baz", 11);
std::string output = Encode(header_list);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000" // prefix
- "2a94e703626172" // foo: bar
- "2a94e703626172" // foo: bar
- "2a94e70362617a" // foo: baz
- ),
+ EXPECT_EQ(absl::HexStringToBytes("0000" // prefix
+ "2a94e703626172" // foo: bar
+ "2a94e703626172" // foo: bar
+ "2a94e70362617a" // foo: baz
+ ),
output);
}
TEST_F(QpackEncoderTest, ZeroInsertCountIncrement) {
// Encoder receives insert count increment with forbidden value 0.
EXPECT_CALL(decoder_stream_error_delegate_,
- OnDecoderStreamError(Eq("Invalid increment value 0.")));
+ OnDecoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT
+ : QUIC_QPACK_DECODER_STREAM_ERROR,
+ Eq("Invalid increment value 0.")));
encoder_.OnInsertCountIncrement(0);
}
@@ -173,10 +181,13 @@ TEST_F(QpackEncoderTest, TooLargeInsertCountIncrement) {
// Encoder receives insert count increment with value that increases Known
// Received Count to a value (one) which is larger than the number of dynamic
// table insertions sent (zero).
- EXPECT_CALL(
- decoder_stream_error_delegate_,
- OnDecoderStreamError(Eq("Increment value 1 raises known received count "
- "to 1 exceeding inserted entry count 0")));
+ EXPECT_CALL(decoder_stream_error_delegate_,
+ OnDecoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT
+ : QUIC_QPACK_DECODER_STREAM_ERROR,
+ Eq("Increment value 1 raises known received count "
+ "to 1 exceeding inserted entry count 0")));
encoder_.OnInsertCountIncrement(1);
}
@@ -197,6 +208,9 @@ TEST_F(QpackEncoderTest, InsertCountIncrementOverflow) {
// received count. This must result in an error instead of a crash.
EXPECT_CALL(decoder_stream_error_delegate_,
OnDecoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_DECODER_STREAM_INCREMENT_OVERFLOW
+ : QUIC_QPACK_DECODER_STREAM_ERROR,
Eq("Insert Count Increment instruction causes overflow.")));
encoder_.OnInsertCountIncrement(std::numeric_limits<uint64_t>::max());
}
@@ -204,10 +218,13 @@ TEST_F(QpackEncoderTest, InsertCountIncrementOverflow) {
TEST_F(QpackEncoderTest, InvalidHeaderAcknowledgement) {
// Encoder receives header acknowledgement for a stream on which no header
// block with dynamic table entries was ever sent.
- EXPECT_CALL(
- decoder_stream_error_delegate_,
- OnDecoderStreamError(Eq("Header Acknowledgement received for stream 0 "
- "with no outstanding header blocks.")));
+ EXPECT_CALL(decoder_stream_error_delegate_,
+ OnDecoderStreamError(
+ GetQuicReloadableFlag(quic_granular_qpack_error_codes)
+ ? QUIC_QPACK_DECODER_STREAM_INCORRECT_ACKNOWLEDGEMENT
+ : QUIC_QPACK_DECODER_STREAM_ERROR,
+ Eq("Header Acknowledgement received for stream 0 "
+ "with no outstanding header blocks.")));
encoder_.OnHeaderAcknowledgement(/* stream_id = */ 0);
}
@@ -216,17 +233,16 @@ TEST_F(QpackEncoderTest, DynamicTable) {
encoder_.SetMaximumDynamicTableCapacity(4096);
encoder_.SetDynamicTableCapacity(4096);
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
header_list.AppendValueOrAddHeader("foo",
"baz"); // name matches dynamic entry
header_list["cookie"] = "baz"; // name matches static entry
// Set Dynamic Table Capacity instruction.
- std::string set_dyanamic_table_capacity =
- quiche::QuicheTextUtils::HexDecode("3fe11f");
+ std::string set_dyanamic_table_capacity = absl::HexStringToBytes("3fe11f");
// Insert three entries into the dynamic table.
- std::string insert_entries = quiche::QuicheTextUtils::HexDecode(
+ std::string insert_entries = absl::HexStringToBytes(
"62" // insert without name reference
"94e7" // Huffman-encoded name "foo"
"03626172" // value "bar"
@@ -238,7 +254,7 @@ TEST_F(QpackEncoderTest, DynamicTable) {
WriteStreamData(Eq(quiche::QuicheStrCat(
set_dyanamic_table_capacity, insert_entries))));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
+ EXPECT_EQ(absl::HexStringToBytes(
"0400" // prefix
"828180"), // dynamic entries with relative index 0, 1, and 2
Encode(header_list));
@@ -252,7 +268,7 @@ TEST_F(QpackEncoderTest, SmallDynamicTable) {
encoder_.SetMaximumDynamicTableCapacity(QpackEntry::Size("foo", "bar"));
encoder_.SetDynamicTableCapacity(QpackEntry::Size("foo", "bar"));
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
header_list.AppendValueOrAddHeader("foo",
"baz"); // name matches dynamic entry
@@ -260,10 +276,9 @@ TEST_F(QpackEncoderTest, SmallDynamicTable) {
header_list["bar"] = "baz"; // no match
// Set Dynamic Table Capacity instruction.
- std::string set_dyanamic_table_capacity =
- quiche::QuicheTextUtils::HexDecode("3f07");
+ std::string set_dyanamic_table_capacity = absl::HexStringToBytes("3f07");
// Insert one entry into the dynamic table.
- std::string insert_entry = quiche::QuicheTextUtils::HexDecode(
+ std::string insert_entry = absl::HexStringToBytes(
"62" // insert without name reference
"94e7" // Huffman-encoded name "foo"
"03626172"); // value "bar"
@@ -271,15 +286,14 @@ TEST_F(QpackEncoderTest, SmallDynamicTable) {
WriteStreamData(Eq(quiche::QuicheStrCat(
set_dyanamic_table_capacity, insert_entry))));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0200" // prefix
- "80" // dynamic entry 0
- "40" // reference to dynamic entry 0 name
- "0362617a" // with literal value "baz"
- "55" // reference to static entry 5 name
- "0362617a" // with literal value "baz"
- "23626172" // literal name "bar"
- "0362617a"), // with literal value "baz"
+ EXPECT_EQ(absl::HexStringToBytes("0200" // prefix
+ "80" // dynamic entry 0
+ "40" // reference to dynamic entry 0 name
+ "0362617a" // with literal value "baz"
+ "55" // reference to static entry 5 name
+ "0362617a" // with literal value "baz"
+ "23626172" // literal name "bar"
+ "0362617a"), // with literal value "baz"
Encode(header_list));
EXPECT_EQ(insert_entry.size(), encoder_stream_sent_byte_count_);
@@ -290,14 +304,13 @@ TEST_F(QpackEncoderTest, BlockedStream) {
encoder_.SetMaximumDynamicTableCapacity(4096);
encoder_.SetDynamicTableCapacity(4096);
- spdy::SpdyHeaderBlock header_list1;
+ spdy::Http2HeaderBlock header_list1;
header_list1["foo"] = "bar";
// Set Dynamic Table Capacity instruction.
- std::string set_dyanamic_table_capacity =
- quiche::QuicheTextUtils::HexDecode("3fe11f");
+ std::string set_dyanamic_table_capacity = absl::HexStringToBytes("3fe11f");
// Insert one entry into the dynamic table.
- std::string insert_entry1 = quiche::QuicheTextUtils::HexDecode(
+ std::string insert_entry1 = absl::HexStringToBytes(
"62" // insert without name reference
"94e7" // Huffman-encoded name "foo"
"03626172"); // value "bar"
@@ -305,30 +318,29 @@ TEST_F(QpackEncoderTest, BlockedStream) {
WriteStreamData(Eq(quiche::QuicheStrCat(
set_dyanamic_table_capacity, insert_entry1))));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0200" // prefix
- "80"), // dynamic entry 0
+ EXPECT_EQ(absl::HexStringToBytes("0200" // prefix
+ "80"), // dynamic entry 0
encoder_.EncodeHeaderList(/* stream_id = */ 1, header_list1,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(insert_entry1.size(), encoder_stream_sent_byte_count_);
// Stream 1 is blocked. Stream 2 is not allowed to block.
- spdy::SpdyHeaderBlock header_list2;
+ spdy::Http2HeaderBlock header_list2;
header_list2["foo"] = "bar"; // name and value match dynamic entry
header_list2.AppendValueOrAddHeader("foo",
"baz"); // name matches dynamic entry
header_list2["cookie"] = "baz"; // name matches static entry
header_list2["bar"] = "baz"; // no match
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0000" // prefix
- "2a94e7" // literal name "foo"
- "03626172" // with literal value "bar"
- "2a94e7" // literal name "foo"
- "0362617a" // with literal value "baz"
- "55" // name of static entry 5
- "0362617a" // with literal value "baz"
- "23626172" // literal name "bar"
- "0362617a"), // with literal value "baz"
+ EXPECT_EQ(absl::HexStringToBytes("0000" // prefix
+ "2a94e7" // literal name "foo"
+ "03626172" // with literal value "bar"
+ "2a94e7" // literal name "foo"
+ "0362617a" // with literal value "baz"
+ "55" // name of static entry 5
+ "0362617a" // with literal value "baz"
+ "23626172" // literal name "bar"
+ "0362617a"), // with literal value "baz"
encoder_.EncodeHeaderList(/* stream_id = */ 2, header_list2,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(0u, encoder_stream_sent_byte_count_);
@@ -338,7 +350,7 @@ TEST_F(QpackEncoderTest, BlockedStream) {
encoder_.OnInsertCountIncrement(1);
// Insert three entries into the dynamic table.
- std::string insert_entries = quiche::QuicheTextUtils::HexDecode(
+ std::string insert_entries = absl::HexStringToBytes(
"80" // insert with name reference, dynamic index 0
"0362617a" // value "baz"
"c5" // insert with name reference, static index 5
@@ -349,23 +361,22 @@ TEST_F(QpackEncoderTest, BlockedStream) {
EXPECT_CALL(encoder_stream_sender_delegate_,
WriteStreamData(Eq(insert_entries)));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0500" // prefix
- "83828180"), // dynamic entries
+ EXPECT_EQ(absl::HexStringToBytes("0500" // prefix
+ "83828180"), // dynamic entries
encoder_.EncodeHeaderList(/* stream_id = */ 3, header_list2,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(insert_entries.size(), encoder_stream_sent_byte_count_);
// Stream 3 is blocked. Stream 4 is not allowed to block, but it can
// reference already acknowledged dynamic entry 0.
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0200" // prefix
- "80" // dynamic entry 0
- "2a94e7" // literal name "foo"
- "0362617a" // with literal value "baz"
- "2c21cfd4c5" // literal name "cookie"
- "0362617a" // with literal value "baz"
- "23626172" // literal name "bar"
- "0362617a"), // with literal value "baz"
+ EXPECT_EQ(absl::HexStringToBytes("0200" // prefix
+ "80" // dynamic entry 0
+ "2a94e7" // literal name "foo"
+ "0362617a" // with literal value "baz"
+ "2c21cfd4c5" // literal name "cookie"
+ "0362617a" // with literal value "baz"
+ "23626172" // literal name "bar"
+ "0362617a"), // with literal value "baz"
encoder_.EncodeHeaderList(/* stream_id = */ 4, header_list2,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(0u, encoder_stream_sent_byte_count_);
@@ -376,11 +387,10 @@ TEST_F(QpackEncoderTest, BlockedStream) {
// Stream 5 is not allowed to block, but it can reference already acknowledged
// dynamic entries 0, 1, and 2.
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0400" // prefix
- "828180" // dynamic entries
- "23626172" // literal name "bar"
- "0362617a"), // with literal value "baz"
+ EXPECT_EQ(absl::HexStringToBytes("0400" // prefix
+ "828180" // dynamic entries
+ "23626172" // literal name "bar"
+ "0362617a"), // with literal value "baz"
encoder_.EncodeHeaderList(/* stream_id = */ 5, header_list2,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(0u, encoder_stream_sent_byte_count_);
@@ -389,15 +399,15 @@ TEST_F(QpackEncoderTest, BlockedStream) {
// Stream 3 is not blocked any longer.
encoder_.OnHeaderAcknowledgement(3);
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0500" // prefix
- "83828180"), // dynamic entries
+ EXPECT_EQ(absl::HexStringToBytes("0500" // prefix
+ "83828180"), // dynamic entries
encoder_.EncodeHeaderList(/* stream_id = */ 6, header_list2,
&encoder_stream_sent_byte_count_));
EXPECT_EQ(0u, encoder_stream_sent_byte_count_);
}
TEST_F(QpackEncoderTest, Draining) {
- spdy::SpdyHeaderBlock header_list1;
+ spdy::Http2HeaderBlock header_list1;
header_list1["one"] = "foo";
header_list1["two"] = "foo";
header_list1["three"] = "foo";
@@ -425,26 +435,24 @@ TEST_F(QpackEncoderTest, Draining) {
// dynamic table.
EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(_));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0b00" // prefix
- "89888786858483828180"), // dynamic entries
+ EXPECT_EQ(absl::HexStringToBytes("0b00" // prefix
+ "89888786858483828180"), // dynamic entries
Encode(header_list1));
// Entry is identical to oldest one, which is draining. It will be
// duplicated and referenced.
- spdy::SpdyHeaderBlock header_list2;
+ spdy::Http2HeaderBlock header_list2;
header_list2["one"] = "foo";
// Duplicate oldest entry.
EXPECT_CALL(encoder_stream_sender_delegate_,
- WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("09"))));
+ WriteStreamData(Eq(absl::HexStringToBytes("09"))));
- EXPECT_EQ(quiche::QuicheTextUtils::HexDecode(
- "0c00" // prefix
- "80"), // most recent dynamic table entry
+ EXPECT_EQ(absl::HexStringToBytes("0c00" // prefix
+ "80"), // most recent dynamic table entry
Encode(header_list2));
- spdy::SpdyHeaderBlock header_list3;
+ spdy::Http2HeaderBlock header_list3;
// Entry is identical to second oldest one, which is draining. There is no
// room to duplicate, it will be encoded with string literals.
header_list3.AppendValueOrAddHeader("two", "foo");
@@ -452,13 +460,12 @@ TEST_F(QpackEncoderTest, Draining) {
// no room to insert new entry, it will be encoded with string literals.
header_list3.AppendValueOrAddHeader("two", "bar");
- EXPECT_EQ(
- quiche::QuicheTextUtils::HexDecode("0000" // prefix
- "2374776f" // literal name "two"
- "8294e7" // literal value "foo"
- "2374776f" // literal name "two"
- "03626172"), // literal value "bar"
- Encode(header_list3));
+ EXPECT_EQ(absl::HexStringToBytes("0000" // prefix
+ "2374776f" // literal name "two"
+ "8294e7" // literal value "foo"
+ "2374776f" // literal name "two"
+ "03626172"), // literal value "bar"
+ Encode(header_list3));
}
TEST_F(QpackEncoderTest, DynamicTableCapacityLessThanMaximum) {
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc
index 29e71488bda..1440ca58a1b 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc
@@ -4,9 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -51,8 +51,8 @@ const QpackEntry* QpackHeaderTable::LookupEntry(bool is_static,
}
QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value,
+ absl::string_view name,
+ absl::string_view value,
bool* is_static,
uint64_t* index) const {
QpackEntry query(name, value);
@@ -96,9 +96,8 @@ QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField(
return MatchType::kNoMatch;
}
-const QpackEntry* QpackHeaderTable::InsertEntry(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+const QpackEntry* QpackHeaderTable::InsertEntry(absl::string_view name,
+ absl::string_view value) {
const uint64_t entry_size = QpackEntry::Size(name, value);
if (entry_size > dynamic_table_capacity_) {
return nullptr;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h
index bed1cc84afa..c9aa767ac10 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h
@@ -10,8 +10,8 @@
#include <queue>
#include <vector>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h"
#include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h"
@@ -70,16 +70,16 @@ class QUIC_EXPORT_PRIVATE QpackHeaderTable {
// Returns the absolute index of an entry with matching name and value if such
// exists, otherwise one with matching name is such exists. |index| is zero
// based for both the static and the dynamic table.
- MatchType FindHeaderField(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value,
+ MatchType FindHeaderField(absl::string_view name,
+ absl::string_view value,
bool* is_static,
uint64_t* index) const;
// Insert (name, value) into the dynamic table. May evict entries. Returns a
// pointer to the inserted owned entry on success. Returns nullptr if entry
// is larger than the capacity of the dynamic table.
- const QpackEntry* InsertEntry(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ const QpackEntry* InsertEntry(absl::string_view name,
+ absl::string_view value);
// Returns the size of the largest entry that could be inserted into the
// dynamic table without evicting entry |index|. |index| might be larger than
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc
index a96159be486..b06786eb437 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc
@@ -6,10 +6,10 @@
#include <utility>
+#include "absl/base/macros.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h"
using ::testing::Mock;
@@ -40,8 +40,8 @@ class QpackHeaderTableTest : public QuicTest {
void ExpectEntryAtIndex(bool is_static,
uint64_t index,
- quiche::QuicheStringPiece expected_name,
- quiche::QuicheStringPiece expected_value) const {
+ absl::string_view expected_name,
+ absl::string_view expected_value) const {
const auto* entry = table_.LookupEntry(is_static, index);
ASSERT_TRUE(entry);
EXPECT_EQ(expected_name, entry->name());
@@ -52,8 +52,8 @@ class QpackHeaderTableTest : public QuicTest {
EXPECT_FALSE(table_.LookupEntry(is_static, index));
}
- void ExpectMatch(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value,
+ void ExpectMatch(absl::string_view name,
+ absl::string_view value,
QpackHeaderTable::MatchType expected_match_type,
bool expected_is_static,
uint64_t expected_index) const {
@@ -70,8 +70,7 @@ class QpackHeaderTableTest : public QuicTest {
EXPECT_EQ(expected_index, index) << name << ": " << value;
}
- void ExpectNoMatch(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) const {
+ void ExpectNoMatch(absl::string_view name, absl::string_view value) const {
bool is_static = false;
uint64_t index = 0;
@@ -82,13 +81,12 @@ class QpackHeaderTableTest : public QuicTest {
<< name << ": " << value;
}
- void InsertEntry(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ void InsertEntry(absl::string_view name, absl::string_view value) {
EXPECT_TRUE(table_.InsertEntry(name, value));
}
- void ExpectToFailInsertingEntry(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ void ExpectToFailInsertingEntry(absl::string_view name,
+ absl::string_view value) {
EXPECT_FALSE(table_.InsertEntry(name, value));
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc
index 1f85d7f1fa7..539e3109cca 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc
@@ -7,9 +7,9 @@
#include <algorithm>
#include <utility>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -33,7 +33,7 @@ QpackInstructionDecoder::QpackInstructionDecoder(const QpackLanguage* language,
error_detected_(false),
state_(State::kStartInstruction) {}
-bool QpackInstructionDecoder::Decode(quiche::QuicheStringPiece data) {
+bool QpackInstructionDecoder::Decode(absl::string_view data) {
DCHECK(!data.empty());
DCHECK(!error_detected_);
@@ -77,8 +77,8 @@ bool QpackInstructionDecoder::Decode(quiche::QuicheStringPiece data) {
DCHECK_LE(bytes_consumed, data.size());
- data = quiche::QuicheStringPiece(data.data() + bytes_consumed,
- data.size() - bytes_consumed);
+ data = absl::string_view(data.data() + bytes_consumed,
+ data.size() - bytes_consumed);
// Stop processing if no more data but next state would require it.
if (data.empty() && (state_ != State::kStartField) &&
@@ -94,8 +94,7 @@ bool QpackInstructionDecoder::AtInstructionBoundary() const {
return state_ == State::kStartInstruction;
}
-bool QpackInstructionDecoder::DoStartInstruction(
- quiche::QuicheStringPiece data) {
+bool QpackInstructionDecoder::DoStartInstruction(absl::string_view data) {
DCHECK(!data.empty());
instruction_ = LookupOpcode(data[0]);
@@ -133,7 +132,7 @@ bool QpackInstructionDecoder::DoStartField() {
}
}
-bool QpackInstructionDecoder::DoReadBit(quiche::QuicheStringPiece data) {
+bool QpackInstructionDecoder::DoReadBit(absl::string_view data) {
DCHECK(!data.empty());
switch (field_->type) {
@@ -163,7 +162,7 @@ bool QpackInstructionDecoder::DoReadBit(quiche::QuicheStringPiece data) {
}
}
-bool QpackInstructionDecoder::DoVarintStart(quiche::QuicheStringPiece data,
+bool QpackInstructionDecoder::DoVarintStart(absl::string_view data,
size_t* bytes_consumed) {
DCHECK(!data.empty());
DCHECK(field_->type == QpackInstructionFieldType::kVarint ||
@@ -184,7 +183,7 @@ bool QpackInstructionDecoder::DoVarintStart(quiche::QuicheStringPiece data,
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;
@@ -192,7 +191,7 @@ bool QpackInstructionDecoder::DoVarintStart(quiche::QuicheStringPiece data,
}
}
-bool QpackInstructionDecoder::DoVarintResume(quiche::QuicheStringPiece data,
+bool QpackInstructionDecoder::DoVarintResume(absl::string_view data,
size_t* bytes_consumed) {
DCHECK(!data.empty());
DCHECK(field_->type == QpackInstructionFieldType::kVarint ||
@@ -213,7 +212,7 @@ bool QpackInstructionDecoder::DoVarintResume(quiche::QuicheStringPiece data,
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;
@@ -245,7 +244,7 @@ bool QpackInstructionDecoder::DoVarintDone() {
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;
}
@@ -265,7 +264,7 @@ bool QpackInstructionDecoder::DoVarintDone() {
return true;
}
-bool QpackInstructionDecoder::DoReadString(quiche::QuicheStringPiece data,
+bool QpackInstructionDecoder::DoReadString(absl::string_view data,
size_t* bytes_consumed) {
DCHECK(!data.empty());
DCHECK(field_->type == QpackInstructionFieldType::kName ||
@@ -299,7 +298,8 @@ bool QpackInstructionDecoder::DoReadStringDone() {
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);
@@ -323,11 +323,12 @@ const QpackInstruction* QpackInstructionDecoder::LookupOpcode(
return nullptr;
}
-void QpackInstructionDecoder::OnError(quiche::QuicheStringPiece error_message) {
+void QpackInstructionDecoder::OnError(ErrorCode error_code,
+ absl::string_view error_message) {
DCHECK(!error_detected_);
error_detected_ = true;
- delegate_->OnError(error_message);
+ delegate_->OnInstructionDecodingError(error_code, error_message);
}
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h
index 08eb665749b..b8edfb7dbf4 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h
@@ -9,11 +9,11 @@
#include <cstdint>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_decoder.h"
#include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_decoder.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -22,6 +22,12 @@ namespace quic {
// fields that follow each instruction.
class QUIC_EXPORT_PRIVATE QpackInstructionDecoder {
public:
+ enum class ErrorCode {
+ INTEGER_TOO_LARGE,
+ STRING_LITERAL_TOO_LONG,
+ HUFFMAN_ENCODING_ERROR,
+ };
+
// Delegate is notified each time an instruction is decoded or when an error
// occurs.
class QUIC_EXPORT_PRIVATE Delegate {
@@ -42,7 +48,9 @@ class QUIC_EXPORT_PRIVATE QpackInstructionDecoder {
// No more data is processed afterwards.
// Implementations are allowed to destroy the QpackInstructionDecoder
// instance synchronously.
- virtual void OnError(quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnInstructionDecodingError(
+ ErrorCode error_code,
+ absl::string_view error_message) = 0;
};
// Both |*language| and |*delegate| must outlive this object.
@@ -53,8 +61,9 @@ class QUIC_EXPORT_PRIVATE QpackInstructionDecoder {
// Provide a data fragment to decode. Must not be called after an error has
// occurred. Must not be called with empty |data|. Return true on success,
- // false on error (in which case Delegate::OnError() is called synchronously).
- bool Decode(quiche::QuicheStringPiece data);
+ // false on error (in which case Delegate::OnInstructionDecodingError() is
+ // called synchronously).
+ bool Decode(absl::string_view data);
// Returns true if no decoding has taken place yet or if the last instruction
// has been entirely parsed.
@@ -94,21 +103,21 @@ class QUIC_EXPORT_PRIVATE QpackInstructionDecoder {
// data and set |*bytes_consumed| to the number of octets processed. Some
// take input data but do not consume any bytes. Some do not take any
// arguments because they only change internal state.
- bool DoStartInstruction(quiche::QuicheStringPiece data);
+ bool DoStartInstruction(absl::string_view data);
bool DoStartField();
- bool DoReadBit(quiche::QuicheStringPiece data);
- bool DoVarintStart(quiche::QuicheStringPiece data, size_t* bytes_consumed);
- bool DoVarintResume(quiche::QuicheStringPiece data, size_t* bytes_consumed);
+ bool DoReadBit(absl::string_view data);
+ bool DoVarintStart(absl::string_view data, size_t* bytes_consumed);
+ bool DoVarintResume(absl::string_view data, size_t* bytes_consumed);
bool DoVarintDone();
- bool DoReadString(quiche::QuicheStringPiece data, size_t* bytes_consumed);
+ bool DoReadString(absl::string_view data, size_t* bytes_consumed);
bool DoReadStringDone();
// Identify instruction based on opcode encoded in |byte|.
// Returns a pointer to an element of |*language_|.
const QpackInstruction* LookupOpcode(uint8_t byte) const;
- // Stops decoding and calls Delegate::OnError().
- void OnError(quiche::QuicheStringPiece error_message);
+ // Stops decoding and calls Delegate::OnInstructionDecodingError().
+ void OnError(ErrorCode error_code, absl::string_view error_message);
// Describes the language used for decoding.
const QpackLanguage* const language_;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc
index a4bbc91aaf5..52ec38bc8c8 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc
@@ -6,17 +6,18 @@
#include <algorithm>
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
using ::testing::_;
using ::testing::Eq;
using ::testing::Expectation;
-using ::testing::Invoke;
+using ::testing::InvokeWithoutArgs;
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::Values;
@@ -66,8 +67,9 @@ class MockDelegate : public QpackInstructionDecoder::Delegate {
(const QpackInstruction*),
(override));
MOCK_METHOD(void,
- OnError,
- (quiche::QuicheStringPiece error_message),
+ OnInstructionDecodingError,
+ (QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message),
(override));
};
@@ -82,11 +84,8 @@ class QpackInstructionDecoderTest : public QuicTestWithParam<FragmentMode> {
void SetUp() override {
// Destroy QpackInstructionDecoder on error to test that it does not crash.
// See https://crbug.com/1025209.
- ON_CALL(delegate_, OnError(_))
- .WillByDefault(
- Invoke([this](quiche::QuicheStringPiece /* error_message */) {
- decoder_.reset();
- }));
+ ON_CALL(delegate_, OnInstructionDecodingError(_, _))
+ .WillByDefault(InvokeWithoutArgs([this]() { decoder_.reset(); }));
}
// Decode one full instruction with fragment sizes dictated by
@@ -95,7 +94,7 @@ class QpackInstructionDecoderTest : public QuicTestWithParam<FragmentMode> {
// verifies that AtInstructionBoundary() returns true before and after the
// instruction, and returns false while decoding is in progress.
// Assumes that delegate methods destroy |decoder_| if they return false.
- void DecodeInstruction(quiche::QuicheStringPiece data) {
+ void DecodeInstruction(absl::string_view data) {
EXPECT_TRUE(decoder_->AtInstructionBoundary());
FragmentSizeGenerator fragment_size_generator =
@@ -132,14 +131,14 @@ INSTANTIATE_TEST_SUITE_P(All,
TEST_P(QpackInstructionDecoderTest, SBitAndVarint2) {
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1()));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("7f01ff65"));
+ DecodeInstruction(absl::HexStringToBytes("7f01ff65"));
EXPECT_TRUE(decoder_->s_bit());
EXPECT_EQ(64u, decoder_->varint());
EXPECT_EQ(356u, decoder_->varint2());
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1()));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("05c8"));
+ DecodeInstruction(absl::HexStringToBytes("05c8"));
EXPECT_FALSE(decoder_->s_bit());
EXPECT_EQ(5u, decoder_->varint());
@@ -148,69 +147,79 @@ TEST_P(QpackInstructionDecoderTest, SBitAndVarint2) {
TEST_P(QpackInstructionDecoderTest, NameAndValue) {
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2()));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("83666f6f03626172"));
+ DecodeInstruction(absl::HexStringToBytes("83666f6f03626172"));
EXPECT_EQ("foo", decoder_->name());
EXPECT_EQ("bar", decoder_->value());
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2()));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("8000"));
+ DecodeInstruction(absl::HexStringToBytes("8000"));
EXPECT_EQ("", decoder_->name());
EXPECT_EQ("", decoder_->value());
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2()));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("c294e7838c767f"));
+ DecodeInstruction(absl::HexStringToBytes("c294e7838c767f"));
EXPECT_EQ("foo", decoder_->name());
EXPECT_EQ("bar", decoder_->value());
}
TEST_P(QpackInstructionDecoderTest, InvalidHuffmanEncoding) {
- EXPECT_CALL(delegate_, OnError(Eq("Error in Huffman-encoded string.")));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("c1ff"));
+ EXPECT_CALL(delegate_,
+ OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode::HUFFMAN_ENCODING_ERROR,
+ Eq("Error in Huffman-encoded string.")));
+ DecodeInstruction(absl::HexStringToBytes("c1ff"));
}
TEST_P(QpackInstructionDecoderTest, InvalidVarintEncoding) {
- EXPECT_CALL(delegate_, OnError(Eq("Encoded integer too large.")));
- DecodeInstruction(
- quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff"));
+ EXPECT_CALL(delegate_,
+ OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode::INTEGER_TOO_LARGE,
+ Eq("Encoded integer too large.")));
+ DecodeInstruction(absl::HexStringToBytes("ffffffffffffffffffffff"));
+}
+
+TEST_P(QpackInstructionDecoderTest, StringLiteralTooLong) {
+ EXPECT_CALL(delegate_,
+ OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode::STRING_LITERAL_TOO_LONG,
+ Eq("String literal too long.")));
+ DecodeInstruction(absl::HexStringToBytes("bfffff7f"));
}
TEST_P(QpackInstructionDecoderTest, DelegateSignalsError) {
// First instruction is valid.
Expectation first_call =
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1()))
- .WillOnce(Invoke(
- [this](const QpackInstruction * /* instruction */) -> bool {
- EXPECT_EQ(1u, decoder_->varint());
- return true;
- }));
+ .WillOnce(InvokeWithoutArgs([this]() -> bool {
+ EXPECT_EQ(1u, decoder_->varint());
+ return true;
+ }));
// Second instruction is invalid. Decoding must halt.
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1()))
.After(first_call)
- .WillOnce(
- Invoke([this](const QpackInstruction * /* instruction */) -> bool {
- EXPECT_EQ(2u, decoder_->varint());
- return false;
- }));
+ .WillOnce(InvokeWithoutArgs([this]() -> bool {
+ EXPECT_EQ(2u, decoder_->varint());
+ return false;
+ }));
- EXPECT_FALSE(decoder_->Decode(
- quiche::QuicheTextUtils::HexDecode("01000200030004000500")));
+ EXPECT_FALSE(
+ decoder_->Decode(absl::HexStringToBytes("01000200030004000500")));
}
// QpackInstructionDecoder must not crash if it is destroyed from a
// Delegate::OnInstructionDecoded() call as long as it returns false.
TEST_P(QpackInstructionDecoderTest, DelegateSignalsErrorAndDestroysDecoder) {
EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1()))
- .WillOnce(
- Invoke([this](const QpackInstruction * /* instruction */) -> bool {
- EXPECT_EQ(1u, decoder_->varint());
- decoder_.reset();
- return false;
- }));
- DecodeInstruction(quiche::QuicheTextUtils::HexDecode("0100"));
+ .WillOnce(InvokeWithoutArgs([this]() -> bool {
+ EXPECT_EQ(1u, decoder_->varint());
+ decoder_.reset();
+ return false;
+ }));
+ DecodeInstruction(absl::HexStringToBytes("0100"));
}
} // namespace
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc
index 41e2d763455..c79665447f9 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc
@@ -6,16 +6,27 @@
#include <limits>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_encoder.h"
#include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_encoder.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
QpackInstructionEncoder::QpackInstructionEncoder()
- : byte_(0), state_(State::kOpcode), instruction_(nullptr) {}
+ : use_huffman_(false),
+ string_length_(0),
+ byte_(0),
+ state_(State::kOpcode),
+ instruction_(nullptr),
+ use_fast_huffman_encoder_(
+ GetQuicReloadableFlag(quic_use_fast_huffman_encoder)) {
+ if (use_fast_huffman_encoder_) {
+ QUIC_RELOADABLE_FLAG_COUNT(quic_use_fast_huffman_encoder);
+ }
+}
void QpackInstructionEncoder::Encode(
const QpackInstructionWithValues& instruction_with_values,
@@ -49,7 +60,8 @@ void QpackInstructionEncoder::Encode(
instruction_with_values.value());
break;
case State::kWriteString:
- DoWriteString(output);
+ DoWriteString(instruction_with_values.name(),
+ instruction_with_values.value(), output);
break;
}
} while (field_ != instruction_->fields.end());
@@ -110,7 +122,7 @@ void QpackInstructionEncoder::DoVarintEncode(uint64_t varint,
integer_to_encode = varint2;
break;
default:
- integer_to_encode = string_to_write_.size();
+ integer_to_encode = string_length_;
break;
}
@@ -128,30 +140,45 @@ void QpackInstructionEncoder::DoVarintEncode(uint64_t varint,
state_ = State::kWriteString;
}
-void QpackInstructionEncoder::DoStartString(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+void QpackInstructionEncoder::DoStartString(absl::string_view name,
+ absl::string_view value) {
DCHECK(field_->type == QpackInstructionFieldType::kName ||
field_->type == QpackInstructionFieldType::kValue);
- string_to_write_ =
+ absl::string_view string_to_write =
(field_->type == QpackInstructionFieldType::kName) ? name : value;
- http2::HuffmanEncode(string_to_write_, &huffman_encoded_string_);
+ string_length_ = string_to_write.size();
- if (huffman_encoded_string_.size() < string_to_write_.size()) {
- DCHECK_EQ(0, byte_ & (1 << field_->param));
+ size_t encoded_size = http2::HuffmanSize(string_to_write);
+ use_huffman_ = encoded_size < string_length_;
+ if (use_huffman_) {
+ DCHECK_EQ(0, byte_ & (1 << field_->param));
byte_ |= (1 << field_->param);
- string_to_write_ = huffman_encoded_string_;
+
+ string_length_ = encoded_size;
}
state_ = State::kVarintEncode;
}
-void QpackInstructionEncoder::DoWriteString(std::string* output) {
+void QpackInstructionEncoder::DoWriteString(absl::string_view name,
+ absl::string_view value,
+ std::string* output) {
DCHECK(field_->type == QpackInstructionFieldType::kName ||
field_->type == QpackInstructionFieldType::kValue);
- QuicStrAppend(output, string_to_write_);
+ absl::string_view string_to_write =
+ (field_->type == QpackInstructionFieldType::kName) ? name : value;
+ if (use_huffman_) {
+ if (use_fast_huffman_encoder_) {
+ http2::HuffmanEncodeFast(string_to_write, string_length_, output);
+ } else {
+ http2::HuffmanEncode(string_to_write, string_length_, output);
+ }
+ } else {
+ QuicStrAppend(output, string_to_write);
+ }
++field_;
state_ = State::kStartField;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h
index 2a955f88db4..4f6fac71c6b 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h
@@ -8,9 +8,9 @@
#include <cstdint>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -38,11 +38,12 @@ class QUIC_EXPORT_PRIVATE QpackInstructionEncoder {
// Encode an integer (|varint_| or |varint2_| or string length) with a
// prefix, using |byte_| for the high bits.
kVarintEncode,
- // Determine if Huffman encoding should be used for |name_| or |value_|, set
- // up |name_| or |value_| and |huffman_encoded_string_| accordingly, and
- // write the Huffman bit to |byte_|.
+ // Determine if Huffman encoding should be used for the header name or
+ // value, set |use_huffman_| and |string_length_| appropriately, write the
+ // Huffman bit to |byte_|.
kStartString,
- // Write string.
+ // Write header name or value, performing Huffman encoding if |use_huffman_|
+ // is true.
kWriteString
};
@@ -52,19 +53,17 @@ class QUIC_EXPORT_PRIVATE QpackInstructionEncoder {
void DoStartField();
void DoSBit(bool s_bit);
void DoVarintEncode(uint64_t varint, uint64_t varint2, std::string* output);
- void DoStartString(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
- void DoWriteString(std::string* output);
+ void DoStartString(absl::string_view name, absl::string_view value);
+ void DoWriteString(absl::string_view name,
+ absl::string_view value,
+ std::string* output);
+ // True if name or value should be Huffman encoded.
+ bool use_huffman_;
- // Storage for the Huffman encoded string literal to be written if Huffman
- // encoding is used.
- std::string huffman_encoded_string_;
-
- // If Huffman encoding is used, points to a substring of
- // |huffman_encoded_string_|.
- // Otherwise points to a substring of |name_| or |value_|.
- quiche::QuicheStringPiece string_to_write_;
+ // Length of name or value string to be written.
+ // If |use_huffman_| is true, length is after Huffman encoding.
+ size_t string_length_;
// Storage for a single byte that contains multiple fields, that is, multiple
// states are writing it.
@@ -78,6 +77,9 @@ class QUIC_EXPORT_PRIVATE QpackInstructionEncoder {
// Field currently being decoded.
QpackInstructionFields::const_iterator field_;
+
+ // Latched value of gfe2_reloadable_flag_quic_use_fast_huffman_encoder.
+ const bool use_fast_huffman_encoder_;
};
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc
index 6f3337c1a61..893bc50670f 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc
@@ -4,9 +4,10 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h"
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h"
namespace quic {
@@ -37,12 +38,12 @@ class QpackInstructionWithValuesPeer {
}
static void set_name(QpackInstructionWithValues* instruction_with_values,
- quiche::QuicheStringPiece name) {
+ absl::string_view name) {
instruction_with_values->name_ = name;
}
static void set_value(QpackInstructionWithValues* instruction_with_values,
- quiche::QuicheStringPiece value) {
+ absl::string_view value) {
instruction_with_values->value_ = value;
}
};
@@ -62,12 +63,10 @@ class QpackInstructionEncoderTest : public QuicTest {
// Compare substring appended to |output_| since last EncodedSegmentMatches()
// call against hex-encoded argument.
- bool EncodedSegmentMatches(
- quiche::QuicheStringPiece hex_encoded_expected_substring) {
+ bool EncodedSegmentMatches(absl::string_view hex_encoded_expected_substring) {
auto recently_encoded =
- quiche::QuicheStringPiece(output_).substr(verified_position_);
- auto expected =
- quiche::QuicheTextUtils::HexDecode(hex_encoded_expected_substring);
+ absl::string_view(output_).substr(verified_position_);
+ auto expected = absl::HexStringToBytes(hex_encoded_expected_substring);
verified_position_ = output_.size();
return recently_encoded == expected;
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc
index 1e5d1124c57..12db3639d39 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc
@@ -6,8 +6,8 @@
#include <limits>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -204,7 +204,7 @@ const QpackLanguage* QpackRequestStreamLanguage() {
QpackInstructionWithValues QpackInstructionWithValues::InsertWithNameReference(
bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value) {
+ absl::string_view value) {
QpackInstructionWithValues instruction_with_values;
instruction_with_values.instruction_ = InsertWithNameReferenceInstruction();
instruction_with_values.s_bit_ = is_static;
@@ -217,8 +217,8 @@ QpackInstructionWithValues QpackInstructionWithValues::InsertWithNameReference(
// static
QpackInstructionWithValues
QpackInstructionWithValues::InsertWithoutNameReference(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ absl::string_view name,
+ absl::string_view value) {
QpackInstructionWithValues instruction_with_values;
instruction_with_values.instruction_ =
InsertWithoutNameReferenceInstruction();
@@ -307,7 +307,7 @@ QpackInstructionWithValues
QpackInstructionWithValues::LiteralHeaderFieldNameReference(
bool is_static,
uint64_t index,
- quiche::QuicheStringPiece value) {
+ absl::string_view value) {
QpackInstructionWithValues instruction_with_values;
instruction_with_values.instruction_ =
QpackLiteralHeaderFieldNameReferenceInstruction();
@@ -320,8 +320,8 @@ QpackInstructionWithValues::LiteralHeaderFieldNameReference(
// static
QpackInstructionWithValues QpackInstructionWithValues::LiteralHeaderField(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) {
+ absl::string_view name,
+ absl::string_view value) {
QpackInstructionWithValues instruction_with_values;
instruction_with_values.instruction_ = QpackLiteralHeaderFieldInstruction();
instruction_with_values.name_ = name;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h
index d63a1e26ba5..006c9a7ab2f 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h
@@ -10,8 +10,8 @@
#include <tuple>
#include <vector>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -151,10 +151,10 @@ class QUIC_EXPORT_PRIVATE QpackInstructionWithValues {
static QpackInstructionWithValues InsertWithNameReference(
bool is_static,
uint64_t name_index,
- quiche::QuicheStringPiece value);
+ absl::string_view value);
static QpackInstructionWithValues InsertWithoutNameReference(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ absl::string_view name,
+ absl::string_view value);
static QpackInstructionWithValues Duplicate(uint64_t index);
static QpackInstructionWithValues SetDynamicTableCapacity(uint64_t capacity);
@@ -172,17 +172,16 @@ class QUIC_EXPORT_PRIVATE QpackInstructionWithValues {
static QpackInstructionWithValues LiteralHeaderFieldNameReference(
bool is_static,
uint64_t index,
- quiche::QuicheStringPiece value);
- static QpackInstructionWithValues LiteralHeaderField(
- quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ absl::string_view value);
+ static QpackInstructionWithValues LiteralHeaderField(absl::string_view name,
+ absl::string_view value);
const QpackInstruction* instruction() const { return instruction_; }
bool s_bit() const { return s_bit_; }
uint64_t varint() const { return varint_; }
uint64_t varint2() const { return varint2_; }
- quiche::QuicheStringPiece name() const { return name_; }
- quiche::QuicheStringPiece value() const { return value_; }
+ absl::string_view name() const { return name_; }
+ absl::string_view value() const { return value_; }
// Used by QpackEncoder, because in the first pass it stores absolute indices,
// which are converted into relative indices in the second pass after base is
@@ -199,8 +198,8 @@ class QUIC_EXPORT_PRIVATE QpackInstructionWithValues {
bool s_bit_;
uint64_t varint_;
uint64_t varint2_;
- quiche::QuicheStringPiece name_;
- quiche::QuicheStringPiece value_;
+ absl::string_view name_;
+ absl::string_view value_;
};
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc
index c1c002fd913..851efe73633 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc
@@ -5,10 +5,10 @@
#include <cstddef>
#include <iostream>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
int main(int argc, char* argv[]) {
const char* usage =
@@ -25,8 +25,8 @@ int main(int argc, char* argv[]) {
size_t i;
size_t success_count = 0;
for (i = 0; 2 * i < args.size(); ++i) {
- const quiche::QuicheStringPiece input_filename(args[2 * i]);
- const quiche::QuicheStringPiece expected_headers_filename(args[2 * i + 1]);
+ const absl::string_view input_filename(args[2 * i]);
+ const absl::string_view expected_headers_filename(args[2 * i + 1]);
// Every file represents a different connection,
// therefore every file needs a fresh decoding context.
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc
index cf20bde3c60..83c55e0b31b 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc
@@ -8,11 +8,11 @@
#include <limits>
#include <utility>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -46,7 +46,7 @@ QpackProgressiveDecoder::~QpackProgressiveDecoder() {
}
}
-void QpackProgressiveDecoder::Decode(quiche::QuicheStringPiece data) {
+void QpackProgressiveDecoder::Decode(absl::string_view data) {
DCHECK(decoding_);
if (data.empty() || error_detected_) {
@@ -89,6 +89,14 @@ void QpackProgressiveDecoder::EndHeaderBlock() {
}
}
+void QpackProgressiveDecoder::OnError(absl::string_view error_message) {
+ DCHECK(!error_detected_);
+
+ error_detected_ = true;
+ // Might destroy |this|.
+ handler_->OnDecodingErrorDetected(error_message);
+}
+
bool QpackProgressiveDecoder::OnInstructionDecoded(
const QpackInstruction* instruction) {
if (instruction == QpackPrefixInstruction()) {
@@ -114,12 +122,13 @@ bool QpackProgressiveDecoder::OnInstructionDecoded(
return DoLiteralHeaderFieldInstruction();
}
-void QpackProgressiveDecoder::OnError(quiche::QuicheStringPiece error_message) {
- DCHECK(!error_detected_);
-
- error_detected_ = true;
- // Might destroy |this|.
- handler_->OnDecodingErrorDetected(error_message);
+void QpackProgressiveDecoder::OnInstructionDecodingError(
+ QpackInstructionDecoder::ErrorCode /* error_code */,
+ absl::string_view error_message) {
+ // Ignore |error_code|, because header block decoding errors trigger a
+ // RESET_STREAM frame which cannot carry an error code more granular than
+ // QPACK_DECOMPRESSION_FAILED.
+ OnError(error_message);
}
void QpackProgressiveDecoder::OnInsertCountReachedThreshold() {
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h
index f9c0224c637..dfc25f9177d 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h
@@ -9,12 +9,12 @@
#include <memory>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -32,8 +32,8 @@ class QUIC_EXPORT_PRIVATE QpackProgressiveDecoder
// Called when a new header name-value pair is decoded. Multiple values for
// a given name will be emitted as multiple calls to OnHeader.
- virtual void OnHeaderDecoded(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value) = 0;
+ virtual void OnHeaderDecoded(absl::string_view name,
+ absl::string_view value) = 0;
// Called when the header block is completely decoded.
// Indicates the total number of bytes in this block.
@@ -46,8 +46,7 @@ class QUIC_EXPORT_PRIVATE QpackProgressiveDecoder
// Called when a decoding error has occurred. No other methods will be
// called afterwards. Implementations are allowed to destroy
// the QpackProgressiveDecoder instance synchronously.
- virtual void OnDecodingErrorDetected(
- quiche::QuicheStringPiece error_message) = 0;
+ virtual void OnDecodingErrorDetected(absl::string_view error_message) = 0;
};
// Interface for keeping track of blocked streams for the purpose of enforcing
@@ -90,15 +89,19 @@ class QUIC_EXPORT_PRIVATE QpackProgressiveDecoder
~QpackProgressiveDecoder() override;
// Provide a data fragment to decode.
- void Decode(quiche::QuicheStringPiece data);
+ void Decode(absl::string_view data);
// Signal that the entire header block has been received and passed in
// through Decode(). No methods must be called afterwards.
void EndHeaderBlock();
+ // Called on error.
+ void OnError(absl::string_view error_message);
+
// QpackInstructionDecoder::Delegate implementation.
bool OnInstructionDecoded(const QpackInstruction* instruction) override;
- void OnError(quiche::QuicheStringPiece error_message) override;
+ void OnInstructionDecodingError(QpackInstructionDecoder::ErrorCode error_code,
+ absl::string_view error_message) override;
// QpackHeaderTable::Observer implementation.
void OnInsertCountReachedThreshold() override;
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc
index b2f15c4ecb3..c7291f7d779 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc
@@ -4,8 +4,8 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/quic_session.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
QpackReceiveStream::QpackReceiveStream(PendingStream* pending,
@@ -25,7 +25,7 @@ void QpackReceiveStream::OnDataAvailable() {
while (!reading_stopped() && sequencer()->GetReadableRegion(&iov)) {
DCHECK(!sequencer()->IsClosed());
- receiver_->Decode(quiche::QuicheStringPiece(
+ receiver_->Decode(absl::string_view(
reinterpret_cast<const char*>(iov.iov_base), iov.iov_len));
sequencer()->MarkConsumed(iov.iov_len);
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc
index 8a8064e5a7e..88cb589a67e 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc
@@ -4,11 +4,11 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/quic_utils.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
namespace test {
@@ -64,7 +64,7 @@ class QpackReceiveStreamTest : public QuicTestWithParam<TestParams> {
: GetNthServerInitiatedUnidirectionalStreamId(
session_.transport_version(), 3);
char type[] = {0x03};
- QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1));
+ QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1));
session_.OnStreamFrame(data1);
qpack_receive_stream_ =
QuicSpdySessionPeer::GetQpackDecoderReceiveStream(&session_);
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc
index fce7de9af01..fca16c04745 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc
@@ -4,8 +4,8 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h"
+#include "absl/base/macros.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
namespace quic {
namespace test {
@@ -50,7 +50,7 @@ struct {
{600, 100, 500}};
TEST(QpackRequiredInsertCountTest, QpackDecodeRequiredInsertCount) {
- for (size_t i = 0; i < QUICHE_ARRAYSIZE(kTestData); ++i) {
+ for (size_t i = 0; i < ABSL_ARRAYSIZE(kTestData); ++i) {
const uint64_t required_insert_count = kTestData[i].required_insert_count;
const uint64_t max_entries = kTestData[i].max_entries;
const uint64_t total_number_of_inserts =
@@ -109,7 +109,7 @@ struct {
{601, 100, 500}};
TEST(QpackRequiredInsertCountTest, DecodeRequiredInsertCountError) {
- for (size_t i = 0; i < QUICHE_ARRAYSIZE(kInvalidTestData); ++i) {
+ for (size_t i = 0; i < ABSL_ARRAYSIZE(kInvalidTestData); ++i) {
uint64_t decoded_required_insert_count = 0;
EXPECT_FALSE(QpackDecodeRequiredInsertCount(
kInvalidTestData[i].encoded_required_insert_count,
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc
index 8625baa3c5c..46e7e887a15 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc
@@ -5,11 +5,11 @@
#include <string>
#include <tuple>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
using ::testing::Values;
@@ -23,8 +23,8 @@ class QpackRoundTripTest : public QuicTestWithParam<FragmentMode> {
QpackRoundTripTest() = default;
~QpackRoundTripTest() override = default;
- spdy::SpdyHeaderBlock EncodeThenDecode(
- const spdy::SpdyHeaderBlock& header_list) {
+ spdy::Http2HeaderBlock EncodeThenDecode(
+ const spdy::Http2HeaderBlock& header_list) {
NoopDecoderStreamErrorDelegate decoder_stream_error_delegate;
NoopQpackStreamSenderDelegate encoder_stream_sender_delegate;
QpackEncoder encoder(&decoder_stream_error_delegate);
@@ -55,80 +55,80 @@ INSTANTIATE_TEST_SUITE_P(All,
FragmentMode::kOctetByOctet));
TEST_P(QpackRoundTripTest, Empty) {
- spdy::SpdyHeaderBlock header_list;
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock header_list;
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
TEST_P(QpackRoundTripTest, EmptyName) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
header_list[""] = "bar";
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
TEST_P(QpackRoundTripTest, EmptyValue) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "";
header_list[""] = "";
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
TEST_P(QpackRoundTripTest, MultipleWithLongEntries) {
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list["foo"] = "bar";
header_list[":path"] = "/";
header_list["foobaar"] = std::string(127, 'Z');
header_list[std::string(1000, 'b')] = std::string(1000, 'c');
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
TEST_P(QpackRoundTripTest, StaticTable) {
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "GET";
header_list["accept-encoding"] = "gzip, deflate";
header_list["cache-control"] = "";
header_list["foo"] = "bar";
header_list[":path"] = "/";
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "POST";
header_list["accept-encoding"] = "brotli";
header_list["cache-control"] = "foo";
header_list["foo"] = "bar";
header_list[":path"] = "/";
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
{
- spdy::SpdyHeaderBlock header_list;
+ spdy::Http2HeaderBlock header_list;
header_list[":method"] = "CONNECT";
header_list["accept-encoding"] = "";
header_list["foo"] = "bar";
header_list[":path"] = "/";
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
}
TEST_P(QpackRoundTripTest, ValueHasNullCharacter) {
- spdy::SpdyHeaderBlock header_list;
- header_list["foo"] = quiche::QuicheStringPiece("bar\0bar\0baz", 11);
+ spdy::Http2HeaderBlock header_list;
+ header_list["foo"] = absl::string_view("bar\0bar\0baz", 11);
- spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list);
+ spdy::Http2HeaderBlock output = EncodeThenDecode(header_list);
EXPECT_EQ(header_list, output);
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc
index 176c431afb9..d6919d73600 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc
@@ -4,9 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h"
+#include "absl/base/macros.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/quic_session.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
QpackSendStream::QpackSendStream(QuicStreamId id,
@@ -27,7 +27,7 @@ bool QpackSendStream::OnStopSending(QuicRstStreamErrorCode /* code */) {
return false;
}
-void QpackSendStream::WriteStreamData(quiche::QuicheStringPiece data) {
+void QpackSendStream::WriteStreamData(absl::string_view data) {
QuicConnection::ScopedPacketFlusher flusher(session()->connection());
MaybeSendStreamType();
WriteOrBufferData(data, false, nullptr);
@@ -36,10 +36,10 @@ void QpackSendStream::WriteStreamData(quiche::QuicheStringPiece data) {
void QpackSendStream::MaybeSendStreamType() {
if (!stream_type_sent_) {
char type[sizeof(http3_stream_type_)];
- QuicDataWriter writer(QUICHE_ARRAYSIZE(type), type);
+ QuicDataWriter writer(ABSL_ARRAYSIZE(type), type);
writer.WriteVarInt62(http3_stream_type_);
- WriteOrBufferData(quiche::QuicheStringPiece(writer.data(), writer.length()),
- false, nullptr);
+ WriteOrBufferData(absl::string_view(writer.data(), writer.length()), false,
+ nullptr);
stream_type_sent_ = true;
}
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h
index e8a4ea797d2..d7f68ee887b 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h
@@ -7,10 +7,10 @@
#include <cstdint>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h"
#include "net/third_party/quiche/src/quic/core/quic_stream.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -41,7 +41,7 @@ class QUIC_EXPORT_PRIVATE QpackSendStream : public QuicStream,
// Writes the instructions to peer. The stream type will be sent
// before the first instruction so that the peer can open an qpack stream.
- void WriteStreamData(quiche::QuicheStringPiece data) override;
+ void WriteStreamData(absl::string_view data) override;
// TODO(b/112770235): Remove this method once QuicStreamIdManager supports
// creating HTTP/3 unidirectional streams dynamically.
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc
index 2ac3289d476..80c89863062 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc
@@ -4,6 +4,8 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h"
+#include "absl/strings/string_view.h"
+#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h"
#include "net/third_party/quiche/src/quic/core/http/http_constants.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h"
@@ -11,7 +13,6 @@
#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
namespace test {
@@ -69,6 +70,9 @@ class QpackSendStreamTest : public QuicTestWithParam<TestParams> {
session_(connection_) {
EXPECT_CALL(session_, OnCongestionWindowChange(_)).Times(AnyNumber());
session_.Initialize();
+ connection_->SetEncrypter(
+ ENCRYPTION_FORWARD_SECURE,
+ std::make_unique<NullEncrypter>(connection_->perspective()));
if (connection_->version().SupportsAntiAmplificationLimit()) {
QuicConnectionPeer::SetAddressValidated(connection_);
}
@@ -104,10 +108,10 @@ TEST_P(QpackSendStreamTest, WriteStreamTypeOnlyFirstTime) {
std::string data = "data";
EXPECT_CALL(session_, WritevData(_, 1, _, _, _, _));
EXPECT_CALL(session_, WritevData(_, data.length(), _, _, _, _));
- qpack_send_stream_->WriteStreamData(quiche::QuicheStringPiece(data));
+ qpack_send_stream_->WriteStreamData(absl::string_view(data));
EXPECT_CALL(session_, WritevData(_, data.length(), _, _, _, _));
- qpack_send_stream_->WriteStreamData(quiche::QuicheStringPiece(data));
+ qpack_send_stream_->WriteStreamData(absl::string_view(data));
EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)).Times(0);
qpack_send_stream_->MaybeSendStreamType();
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc
index 17138be94d5..e88abe00026 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc
@@ -4,15 +4,15 @@
#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h"
+#include "absl/base/macros.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
namespace quic {
// The "constructor" for a QpackStaticEntry that computes the lengths at
// compile time.
#define STATIC_ENTRY(name, value) \
- { name, QUICHE_ARRAYSIZE(name) - 1, value, QUICHE_ARRAYSIZE(value) - 1 }
+ { name, ABSL_ARRAYSIZE(name) - 1, value, ABSL_ARRAYSIZE(value) - 1 }
const std::vector<QpackStaticEntry>& QpackStaticTableVector() {
static const auto* kQpackStaticTable = new std::vector<QpackStaticEntry>{
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc
index 1376d2cd51a..a771cf3862d 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc
@@ -6,9 +6,9 @@
#include <set>
+#include "absl/base/macros.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -32,7 +32,7 @@ TEST(QpackStaticTableTest, Initialize) {
EXPECT_EQ(QpackStaticTableVector().size(), static_index.size());
auto static_name_index = table.GetStaticNameIndex();
- std::set<quiche::QuicheStringPiece> names;
+ std::set<absl::string_view> names;
for (auto entry : static_index) {
names.insert(entry->name());
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h
index 01c2d5f4237..d7c4b550b1b 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h
@@ -5,8 +5,8 @@
#ifndef QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_
#define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -16,7 +16,7 @@ class QUIC_EXPORT_PRIVATE QpackStreamReceiver {
virtual ~QpackStreamReceiver() = default;
// Decode data.
- virtual void Decode(quiche::QuicheStringPiece data) = 0;
+ virtual void Decode(absl::string_view data) = 0;
};
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h
index 524b756653d..9f3faf80bb1 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h
@@ -5,8 +5,8 @@
#ifndef QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_SENDER_DELEGATE_H_
#define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_SENDER_DELEGATE_H_
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
@@ -16,7 +16,7 @@ class QUIC_EXPORT_PRIVATE QpackStreamSenderDelegate {
virtual ~QpackStreamSenderDelegate() = default;
// Write data on the unidirectional stream.
- virtual void WriteStreamData(quiche::QuicheStringPiece data) = 0;
+ virtual void WriteStreamData(absl::string_view data) = 0;
};
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc
index 65d1b99e0a8..c18610939f1 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
+#include "absl/strings/string_view.h"
namespace quic {
namespace {
@@ -16,8 +16,8 @@ const char kNonCookieSeparator = '\0';
} // namespace
ValueSplittingHeaderList::const_iterator::const_iterator(
- const spdy::SpdyHeaderBlock* header_list,
- spdy::SpdyHeaderBlock::const_iterator header_list_iterator)
+ const spdy::Http2HeaderBlock* header_list,
+ spdy::Http2HeaderBlock::const_iterator header_list_iterator)
: header_list_(header_list),
header_list_iterator_(header_list_iterator),
value_start_(0) {
@@ -37,7 +37,7 @@ bool ValueSplittingHeaderList::const_iterator::operator!=(
const ValueSplittingHeaderList::const_iterator&
ValueSplittingHeaderList::const_iterator::operator++() {
- if (value_end_ == quiche::QuicheStringPiece::npos) {
+ if (value_end_ == absl::string_view::npos) {
// This was the last frament within |*header_list_iterator_|,
// move on to the next header element of |header_list_|.
++header_list_iterator_;
@@ -61,15 +61,14 @@ const ValueSplittingHeaderList::value_type*
}
void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() {
- DCHECK(value_start_ != quiche::QuicheStringPiece::npos);
+ DCHECK(value_start_ != absl::string_view::npos);
if (header_list_iterator_ == header_list_->end()) {
return;
}
- const quiche::QuicheStringPiece name = header_list_iterator_->first;
- const quiche::QuicheStringPiece original_value =
- header_list_iterator_->second;
+ const absl::string_view name = header_list_iterator_->first;
+ const absl::string_view original_value = header_list_iterator_->second;
if (name == kCookieKey) {
value_end_ = original_value.find(kCookieSeparator, value_start_);
@@ -77,12 +76,12 @@ void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() {
value_end_ = original_value.find(kNonCookieSeparator, value_start_);
}
- const quiche::QuicheStringPiece value =
+ const absl::string_view value =
original_value.substr(value_start_, value_end_ - value_start_);
header_field_ = std::make_pair(name, value);
// Skip character after ';' separator if it is a space.
- if (name == kCookieKey && value_end_ != quiche::QuicheStringPiece::npos &&
+ if (name == kCookieKey && value_end_ != absl::string_view::npos &&
value_end_ + 1 < original_value.size() &&
original_value[value_end_ + 1] == kOptionalSpaceAfterCookieSeparator) {
++value_end_;
@@ -90,7 +89,7 @@ void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() {
}
ValueSplittingHeaderList::ValueSplittingHeaderList(
- const spdy::SpdyHeaderBlock* header_list)
+ const spdy::Http2HeaderBlock* header_list)
: header_list_(header_list) {
DCHECK(header_list_);
}
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h
index 446548a23ab..06518a59075 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h
@@ -5,24 +5,24 @@
#ifndef QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_
#define QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
namespace quic {
-// A wrapper class around SpdyHeaderBlock that splits header values along ';'
+// A wrapper class around Http2HeaderBlock that splits header values along ';'
// separators (while also removing optional space following separator) for
// cookies and along '\0' separators for other header fields.
class QUIC_EXPORT_PRIVATE ValueSplittingHeaderList {
public:
- using value_type = spdy::SpdyHeaderBlock::value_type;
+ using value_type = spdy::Http2HeaderBlock::value_type;
class QUIC_EXPORT_PRIVATE const_iterator {
public:
// |header_list| must outlive this object.
- const_iterator(const spdy::SpdyHeaderBlock* header_list,
- spdy::SpdyHeaderBlock::const_iterator header_list_iterator);
+ const_iterator(const spdy::Http2HeaderBlock* header_list,
+ spdy::Http2HeaderBlock::const_iterator header_list_iterator);
const_iterator(const const_iterator&) = default;
const_iterator& operator=(const const_iterator&) = delete;
@@ -38,15 +38,15 @@ class QUIC_EXPORT_PRIVATE ValueSplittingHeaderList {
// Find next separator; update |value_end_| and |header_field_|.
void UpdateHeaderField();
- const spdy::SpdyHeaderBlock* const header_list_;
- spdy::SpdyHeaderBlock::const_iterator header_list_iterator_;
- quiche::QuicheStringPiece::size_type value_start_;
- quiche::QuicheStringPiece::size_type value_end_;
+ const spdy::Http2HeaderBlock* const header_list_;
+ spdy::Http2HeaderBlock::const_iterator header_list_iterator_;
+ absl::string_view::size_type value_start_;
+ absl::string_view::size_type value_end_;
value_type header_field_;
};
// |header_list| must outlive this object.
- explicit ValueSplittingHeaderList(const spdy::SpdyHeaderBlock* header_list);
+ explicit ValueSplittingHeaderList(const spdy::Http2HeaderBlock* header_list);
ValueSplittingHeaderList(const ValueSplittingHeaderList&) = delete;
ValueSplittingHeaderList& operator=(const ValueSplittingHeaderList&) = delete;
@@ -54,7 +54,7 @@ class QUIC_EXPORT_PRIVATE ValueSplittingHeaderList {
const_iterator end() const;
private:
- const spdy::SpdyHeaderBlock* const header_list_;
+ const spdy::Http2HeaderBlock* const header_list_;
};
} // namespace quic
diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc
index c1da85c8cd0..0fc04ccbf56 100644
--- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc
@@ -4,9 +4,9 @@
#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h"
+#include "absl/base/macros.h"
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
namespace test {
@@ -16,8 +16,8 @@ using ::testing::ElementsAre;
using ::testing::Pair;
TEST(ValueSplittingHeaderListTest, Comparison) {
- spdy::SpdyHeaderBlock block;
- block["foo"] = quiche::QuicheStringPiece("bar\0baz", 7);
+ spdy::Http2HeaderBlock block;
+ block["foo"] = absl::string_view("bar\0baz", 7);
block["baz"] = "qux";
block["cookie"] = "foo; bar";
@@ -75,7 +75,7 @@ TEST(ValueSplittingHeaderListTest, Comparison) {
}
TEST(ValueSplittingHeaderListTest, Empty) {
- spdy::SpdyHeaderBlock block;
+ spdy::Http2HeaderBlock block;
ValueSplittingHeaderList headers(&block);
EXPECT_THAT(headers, ElementsAre());
@@ -85,7 +85,7 @@ TEST(ValueSplittingHeaderListTest, Empty) {
TEST(ValueSplittingHeaderListTest, Split) {
struct {
const char* name;
- quiche::QuicheStringPiece value;
+ absl::string_view value;
std::vector<const char*> expected_values;
} kTestData[]{
// Empty value.
@@ -113,8 +113,8 @@ TEST(ValueSplittingHeaderListTest, Split) {
{"cookie", "; foobar; ", {"", "foobar", ""}},
};
- for (size_t i = 0; i < QUICHE_ARRAYSIZE(kTestData); ++i) {
- spdy::SpdyHeaderBlock block;
+ for (size_t i = 0; i < ABSL_ARRAYSIZE(kTestData); ++i) {
+ spdy::Http2HeaderBlock block;
block[kTestData[i].name] = kTestData[i].value;
ValueSplittingHeaderList headers(&block);
@@ -130,10 +130,10 @@ TEST(ValueSplittingHeaderListTest, Split) {
}
TEST(ValueSplittingHeaderListTest, MultipleFields) {
- spdy::SpdyHeaderBlock block;
- block["foo"] = quiche::QuicheStringPiece("bar\0baz\0", 8);
+ spdy::Http2HeaderBlock block;
+ block["foo"] = absl::string_view("bar\0baz\0", 8);
block["cookie"] = "foo; bar";
- block["bar"] = quiche::QuicheStringPiece("qux\0foo", 7);
+ block["bar"] = absl::string_view("qux\0foo", 7);
ValueSplittingHeaderList headers(&block);
EXPECT_THAT(headers, ElementsAre(Pair("foo", "bar"), Pair("foo", "baz"),
@@ -143,7 +143,7 @@ TEST(ValueSplittingHeaderListTest, MultipleFields) {
}
TEST(ValueSplittingHeaderListTest, CookieStartsWithSpace) {
- spdy::SpdyHeaderBlock block;
+ spdy::Http2HeaderBlock block;
block["foo"] = "bar";
block["cookie"] = " foo";
block["bar"] = "baz";