summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc')
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc52
1 files changed, 32 insertions, 20 deletions
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