Moves some build targets from //third_party/spdy/core/hpack to //third_party/http2/hpack.
This change leaves behind vestigial targets and an include file so that we can defer changes to //third_party/envoy.
Protected by refactoring, not protected.
PiperOrigin-RevId: 650714068
diff --git a/build/source_list.bzl b/build/source_list.bzl
index aa4e3cb..d1384fc 100644
--- a/build/source_list.bzl
+++ b/build/source_list.bzl
@@ -111,6 +111,12 @@
"http2/hpack/decoder/hpack_string_decoder_listener.h",
"http2/hpack/decoder/hpack_whole_entry_buffer.h",
"http2/hpack/decoder/hpack_whole_entry_listener.h",
+ "http2/hpack/hpack_constants.h",
+ "http2/hpack/hpack_encoder.h",
+ "http2/hpack/hpack_entry.h",
+ "http2/hpack/hpack_header_table.h",
+ "http2/hpack/hpack_output_stream.h",
+ "http2/hpack/hpack_static_table.h",
"http2/hpack/http2_hpack_constants.h",
"http2/hpack/huffman/hpack_huffman_decoder.h",
"http2/hpack/huffman/hpack_huffman_encoder.h",
@@ -375,13 +381,8 @@
"quic/platform/api/quic_thread.h",
"spdy/core/array_output_buffer.h",
"spdy/core/header_byte_listener_interface.h",
- "spdy/core/hpack/hpack_constants.h",
"spdy/core/hpack/hpack_decoder_adapter.h",
"spdy/core/hpack/hpack_encoder.h",
- "spdy/core/hpack/hpack_entry.h",
- "spdy/core/hpack/hpack_header_table.h",
- "spdy/core/hpack/hpack_output_stream.h",
- "spdy/core/hpack/hpack_static_table.h",
"spdy/core/http2_frame_decoder_adapter.h",
"spdy/core/http2_header_block.h",
"spdy/core/http2_header_block_hpack_listener.h",
@@ -466,6 +467,12 @@
"http2/hpack/decoder/hpack_string_decoder_listener.cc",
"http2/hpack/decoder/hpack_whole_entry_buffer.cc",
"http2/hpack/decoder/hpack_whole_entry_listener.cc",
+ "http2/hpack/hpack_constants.cc",
+ "http2/hpack/hpack_encoder.cc",
+ "http2/hpack/hpack_entry.cc",
+ "http2/hpack/hpack_header_table.cc",
+ "http2/hpack/hpack_output_stream.cc",
+ "http2/hpack/hpack_static_table.cc",
"http2/hpack/http2_hpack_constants.cc",
"http2/hpack/huffman/hpack_huffman_decoder.cc",
"http2/hpack/huffman/hpack_huffman_encoder.cc",
@@ -677,13 +684,7 @@
"quic/core/web_transport_write_blocked_list.cc",
"quic/platform/api/quic_socket_address.cc",
"spdy/core/array_output_buffer.cc",
- "spdy/core/hpack/hpack_constants.cc",
"spdy/core/hpack/hpack_decoder_adapter.cc",
- "spdy/core/hpack/hpack_encoder.cc",
- "spdy/core/hpack/hpack_entry.cc",
- "spdy/core/hpack/hpack_header_table.cc",
- "spdy/core/hpack/hpack_output_stream.cc",
- "spdy/core/hpack/hpack_static_table.cc",
"spdy/core/http2_frame_decoder_adapter.cc",
"spdy/core/recording_headers_handler.cc",
"spdy/core/spdy_alt_svc_wire_format.cc",
@@ -1138,6 +1139,11 @@
"http2/hpack/decoder/hpack_entry_type_decoder_test.cc",
"http2/hpack/decoder/hpack_string_decoder_test.cc",
"http2/hpack/decoder/hpack_whole_entry_buffer_test.cc",
+ "http2/hpack/hpack_encoder_test.cc",
+ "http2/hpack/hpack_entry_test.cc",
+ "http2/hpack/hpack_header_table_test.cc",
+ "http2/hpack/hpack_output_stream_test.cc",
+ "http2/hpack/hpack_static_table_test.cc",
"http2/hpack/http2_hpack_constants_test.cc",
"http2/hpack/huffman/hpack_huffman_decoder_test.cc",
"http2/hpack/huffman/hpack_huffman_encoder_test.cc",
@@ -1318,12 +1324,7 @@
"quic/tools/simple_ticket_crypter_test.cc",
"spdy/core/array_output_buffer_test.cc",
"spdy/core/hpack/hpack_decoder_adapter_test.cc",
- "spdy/core/hpack/hpack_encoder_test.cc",
- "spdy/core/hpack/hpack_entry_test.cc",
- "spdy/core/hpack/hpack_header_table_test.cc",
- "spdy/core/hpack/hpack_output_stream_test.cc",
"spdy/core/hpack/hpack_round_trip_test.cc",
- "spdy/core/hpack/hpack_static_table_test.cc",
"spdy/core/spdy_alt_svc_wire_format_test.cc",
"spdy/core/spdy_frame_builder_test.cc",
"spdy/core/spdy_framer_test.cc",
diff --git a/build/source_list.gni b/build/source_list.gni
index b73efd8..d6016bf 100644
--- a/build/source_list.gni
+++ b/build/source_list.gni
@@ -111,6 +111,12 @@
"src/quiche/http2/hpack/decoder/hpack_string_decoder_listener.h",
"src/quiche/http2/hpack/decoder/hpack_whole_entry_buffer.h",
"src/quiche/http2/hpack/decoder/hpack_whole_entry_listener.h",
+ "src/quiche/http2/hpack/hpack_constants.h",
+ "src/quiche/http2/hpack/hpack_encoder.h",
+ "src/quiche/http2/hpack/hpack_entry.h",
+ "src/quiche/http2/hpack/hpack_header_table.h",
+ "src/quiche/http2/hpack/hpack_output_stream.h",
+ "src/quiche/http2/hpack/hpack_static_table.h",
"src/quiche/http2/hpack/http2_hpack_constants.h",
"src/quiche/http2/hpack/huffman/hpack_huffman_decoder.h",
"src/quiche/http2/hpack/huffman/hpack_huffman_encoder.h",
@@ -375,13 +381,8 @@
"src/quiche/quic/platform/api/quic_thread.h",
"src/quiche/spdy/core/array_output_buffer.h",
"src/quiche/spdy/core/header_byte_listener_interface.h",
- "src/quiche/spdy/core/hpack/hpack_constants.h",
"src/quiche/spdy/core/hpack/hpack_decoder_adapter.h",
"src/quiche/spdy/core/hpack/hpack_encoder.h",
- "src/quiche/spdy/core/hpack/hpack_entry.h",
- "src/quiche/spdy/core/hpack/hpack_header_table.h",
- "src/quiche/spdy/core/hpack/hpack_output_stream.h",
- "src/quiche/spdy/core/hpack/hpack_static_table.h",
"src/quiche/spdy/core/http2_frame_decoder_adapter.h",
"src/quiche/spdy/core/http2_header_block.h",
"src/quiche/spdy/core/http2_header_block_hpack_listener.h",
@@ -466,6 +467,12 @@
"src/quiche/http2/hpack/decoder/hpack_string_decoder_listener.cc",
"src/quiche/http2/hpack/decoder/hpack_whole_entry_buffer.cc",
"src/quiche/http2/hpack/decoder/hpack_whole_entry_listener.cc",
+ "src/quiche/http2/hpack/hpack_constants.cc",
+ "src/quiche/http2/hpack/hpack_encoder.cc",
+ "src/quiche/http2/hpack/hpack_entry.cc",
+ "src/quiche/http2/hpack/hpack_header_table.cc",
+ "src/quiche/http2/hpack/hpack_output_stream.cc",
+ "src/quiche/http2/hpack/hpack_static_table.cc",
"src/quiche/http2/hpack/http2_hpack_constants.cc",
"src/quiche/http2/hpack/huffman/hpack_huffman_decoder.cc",
"src/quiche/http2/hpack/huffman/hpack_huffman_encoder.cc",
@@ -677,13 +684,7 @@
"src/quiche/quic/core/web_transport_write_blocked_list.cc",
"src/quiche/quic/platform/api/quic_socket_address.cc",
"src/quiche/spdy/core/array_output_buffer.cc",
- "src/quiche/spdy/core/hpack/hpack_constants.cc",
"src/quiche/spdy/core/hpack/hpack_decoder_adapter.cc",
- "src/quiche/spdy/core/hpack/hpack_encoder.cc",
- "src/quiche/spdy/core/hpack/hpack_entry.cc",
- "src/quiche/spdy/core/hpack/hpack_header_table.cc",
- "src/quiche/spdy/core/hpack/hpack_output_stream.cc",
- "src/quiche/spdy/core/hpack/hpack_static_table.cc",
"src/quiche/spdy/core/http2_frame_decoder_adapter.cc",
"src/quiche/spdy/core/recording_headers_handler.cc",
"src/quiche/spdy/core/spdy_alt_svc_wire_format.cc",
@@ -1139,6 +1140,11 @@
"src/quiche/http2/hpack/decoder/hpack_entry_type_decoder_test.cc",
"src/quiche/http2/hpack/decoder/hpack_string_decoder_test.cc",
"src/quiche/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc",
+ "src/quiche/http2/hpack/hpack_encoder_test.cc",
+ "src/quiche/http2/hpack/hpack_entry_test.cc",
+ "src/quiche/http2/hpack/hpack_header_table_test.cc",
+ "src/quiche/http2/hpack/hpack_output_stream_test.cc",
+ "src/quiche/http2/hpack/hpack_static_table_test.cc",
"src/quiche/http2/hpack/http2_hpack_constants_test.cc",
"src/quiche/http2/hpack/huffman/hpack_huffman_decoder_test.cc",
"src/quiche/http2/hpack/huffman/hpack_huffman_encoder_test.cc",
@@ -1319,12 +1325,7 @@
"src/quiche/quic/tools/simple_ticket_crypter_test.cc",
"src/quiche/spdy/core/array_output_buffer_test.cc",
"src/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc",
- "src/quiche/spdy/core/hpack/hpack_encoder_test.cc",
- "src/quiche/spdy/core/hpack/hpack_entry_test.cc",
- "src/quiche/spdy/core/hpack/hpack_header_table_test.cc",
- "src/quiche/spdy/core/hpack/hpack_output_stream_test.cc",
"src/quiche/spdy/core/hpack/hpack_round_trip_test.cc",
- "src/quiche/spdy/core/hpack/hpack_static_table_test.cc",
"src/quiche/spdy/core/spdy_alt_svc_wire_format_test.cc",
"src/quiche/spdy/core/spdy_frame_builder_test.cc",
"src/quiche/spdy/core/spdy_framer_test.cc",
diff --git a/build/source_list.json b/build/source_list.json
index c6d3fdc..f2b726e 100644
--- a/build/source_list.json
+++ b/build/source_list.json
@@ -110,6 +110,12 @@
"quiche/http2/hpack/decoder/hpack_string_decoder_listener.h",
"quiche/http2/hpack/decoder/hpack_whole_entry_buffer.h",
"quiche/http2/hpack/decoder/hpack_whole_entry_listener.h",
+ "quiche/http2/hpack/hpack_constants.h",
+ "quiche/http2/hpack/hpack_encoder.h",
+ "quiche/http2/hpack/hpack_entry.h",
+ "quiche/http2/hpack/hpack_header_table.h",
+ "quiche/http2/hpack/hpack_output_stream.h",
+ "quiche/http2/hpack/hpack_static_table.h",
"quiche/http2/hpack/http2_hpack_constants.h",
"quiche/http2/hpack/huffman/hpack_huffman_decoder.h",
"quiche/http2/hpack/huffman/hpack_huffman_encoder.h",
@@ -374,13 +380,8 @@
"quiche/quic/platform/api/quic_thread.h",
"quiche/spdy/core/array_output_buffer.h",
"quiche/spdy/core/header_byte_listener_interface.h",
- "quiche/spdy/core/hpack/hpack_constants.h",
"quiche/spdy/core/hpack/hpack_decoder_adapter.h",
"quiche/spdy/core/hpack/hpack_encoder.h",
- "quiche/spdy/core/hpack/hpack_entry.h",
- "quiche/spdy/core/hpack/hpack_header_table.h",
- "quiche/spdy/core/hpack/hpack_output_stream.h",
- "quiche/spdy/core/hpack/hpack_static_table.h",
"quiche/spdy/core/http2_frame_decoder_adapter.h",
"quiche/spdy/core/http2_header_block.h",
"quiche/spdy/core/http2_header_block_hpack_listener.h",
@@ -465,6 +466,12 @@
"quiche/http2/hpack/decoder/hpack_string_decoder_listener.cc",
"quiche/http2/hpack/decoder/hpack_whole_entry_buffer.cc",
"quiche/http2/hpack/decoder/hpack_whole_entry_listener.cc",
+ "quiche/http2/hpack/hpack_constants.cc",
+ "quiche/http2/hpack/hpack_encoder.cc",
+ "quiche/http2/hpack/hpack_entry.cc",
+ "quiche/http2/hpack/hpack_header_table.cc",
+ "quiche/http2/hpack/hpack_output_stream.cc",
+ "quiche/http2/hpack/hpack_static_table.cc",
"quiche/http2/hpack/http2_hpack_constants.cc",
"quiche/http2/hpack/huffman/hpack_huffman_decoder.cc",
"quiche/http2/hpack/huffman/hpack_huffman_encoder.cc",
@@ -676,13 +683,7 @@
"quiche/quic/core/web_transport_write_blocked_list.cc",
"quiche/quic/platform/api/quic_socket_address.cc",
"quiche/spdy/core/array_output_buffer.cc",
- "quiche/spdy/core/hpack/hpack_constants.cc",
"quiche/spdy/core/hpack/hpack_decoder_adapter.cc",
- "quiche/spdy/core/hpack/hpack_encoder.cc",
- "quiche/spdy/core/hpack/hpack_entry.cc",
- "quiche/spdy/core/hpack/hpack_header_table.cc",
- "quiche/spdy/core/hpack/hpack_output_stream.cc",
- "quiche/spdy/core/hpack/hpack_static_table.cc",
"quiche/spdy/core/http2_frame_decoder_adapter.cc",
"quiche/spdy/core/recording_headers_handler.cc",
"quiche/spdy/core/spdy_alt_svc_wire_format.cc",
@@ -1138,6 +1139,11 @@
"quiche/http2/hpack/decoder/hpack_entry_type_decoder_test.cc",
"quiche/http2/hpack/decoder/hpack_string_decoder_test.cc",
"quiche/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc",
+ "quiche/http2/hpack/hpack_encoder_test.cc",
+ "quiche/http2/hpack/hpack_entry_test.cc",
+ "quiche/http2/hpack/hpack_header_table_test.cc",
+ "quiche/http2/hpack/hpack_output_stream_test.cc",
+ "quiche/http2/hpack/hpack_static_table_test.cc",
"quiche/http2/hpack/http2_hpack_constants_test.cc",
"quiche/http2/hpack/huffman/hpack_huffman_decoder_test.cc",
"quiche/http2/hpack/huffman/hpack_huffman_encoder_test.cc",
@@ -1318,12 +1324,7 @@
"quiche/quic/tools/simple_ticket_crypter_test.cc",
"quiche/spdy/core/array_output_buffer_test.cc",
"quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc",
- "quiche/spdy/core/hpack/hpack_encoder_test.cc",
- "quiche/spdy/core/hpack/hpack_entry_test.cc",
- "quiche/spdy/core/hpack/hpack_header_table_test.cc",
- "quiche/spdy/core/hpack/hpack_output_stream_test.cc",
"quiche/spdy/core/hpack/hpack_round_trip_test.cc",
- "quiche/spdy/core/hpack/hpack_static_table_test.cc",
"quiche/spdy/core/spdy_alt_svc_wire_format_test.cc",
"quiche/spdy/core/spdy_frame_builder_test.cc",
"quiche/spdy/core/spdy_framer_test.cc",
diff --git a/quiche/http2/adapter/test_frame_sequence.cc b/quiche/http2/adapter/test_frame_sequence.cc
index bae140d..833d17a 100644
--- a/quiche/http2/adapter/test_frame_sequence.cc
+++ b/quiche/http2/adapter/test_frame_sequence.cc
@@ -8,7 +8,7 @@
#include "quiche/http2/adapter/http2_util.h"
#include "quiche/http2/adapter/oghttp2_util.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/spdy/core/spdy_framer.h"
namespace http2 {
diff --git a/quiche/http2/adapter/test_utils.cc b/quiche/http2/adapter/test_utils.cc
index 8871f0a..b791443 100644
--- a/quiche/http2/adapter/test_utils.cc
+++ b/quiche/http2/adapter/test_utils.cc
@@ -7,8 +7,8 @@
#include "absl/strings/str_format.h"
#include "quiche/http2/adapter/http2_visitor_interface.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/common/quiche_data_reader.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
#include "quiche/spdy/core/spdy_protocol.h"
namespace http2 {
diff --git a/quiche/spdy/core/hpack/hpack_constants.cc b/quiche/http2/hpack/hpack_constants.cc
similarity index 99%
rename from quiche/spdy/core/hpack/hpack_constants.cc
rename to quiche/http2/hpack/hpack_constants.cc
index 12d720b..5eea1ae 100644
--- a/quiche/spdy/core/hpack/hpack_constants.cc
+++ b/quiche/http2/hpack/hpack_constants.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_constants.h"
#include <vector>
#include "absl/base/macros.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_constants.h b/quiche/http2/hpack/hpack_constants.h
similarity index 94%
rename from quiche/spdy/core/hpack/hpack_constants.h
rename to quiche/http2/hpack/hpack_constants.h
index a92f975..65acab2 100644
--- a/quiche/spdy/core/hpack/hpack_constants.h
+++ b/quiche/http2/hpack/hpack_constants.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_CONSTANTS_H_
-#define QUICHE_SPDY_CORE_HPACK_HPACK_CONSTANTS_H_
+#ifndef QUICHE_HTTP2_HPACK_HPACK_CONSTANTS_H_
+#define QUICHE_HTTP2_HPACK_HPACK_CONSTANTS_H_
#include <cstddef>
#include <cstdint>
@@ -85,4 +85,4 @@
} // namespace spdy
-#endif // QUICHE_SPDY_CORE_HPACK_HPACK_CONSTANTS_H_
+#endif // QUICHE_HTTP2_HPACK_HPACK_CONSTANTS_H_
diff --git a/quiche/spdy/core/hpack/hpack_encoder.cc b/quiche/http2/hpack/hpack_encoder.cc
similarity index 98%
rename from quiche/spdy/core/hpack/hpack_encoder.cc
rename to quiche/http2/hpack/hpack_encoder.cc
index 8d0e841..625ee70 100644
--- a/quiche/spdy/core/hpack/hpack_encoder.cc
+++ b/quiche/http2/hpack/hpack_encoder.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include <algorithm>
#include <cstddef>
@@ -14,12 +14,12 @@
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
#include "quiche/http2/hpack/huffman/hpack_huffman_encoder.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
#include "quiche/spdy/core/http2_header_block.h"
namespace spdy {
diff --git a/quiche/http2/hpack/hpack_encoder.h b/quiche/http2/hpack/hpack_encoder.h
new file mode 100644
index 0000000..3130ca5
--- /dev/null
+++ b/quiche/http2/hpack/hpack_encoder.h
@@ -0,0 +1,156 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef QUICHE_HTTP2_HPACK_HPACK_ENCODER_H_
+#define QUICHE_HTTP2_HPACK_HPACK_ENCODER_H_
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
+#include "quiche/common/platform/api/quiche_export.h"
+#include "quiche/common/quiche_callbacks.h"
+#include "quiche/spdy/core/http2_header_block.h"
+
+// An HpackEncoder encodes header sets as outlined in
+// http://tools.ietf.org/html/rfc7541.
+
+namespace spdy {
+
+namespace test {
+class HpackEncoderPeer;
+} // namespace test
+
+class QUICHE_EXPORT HpackEncoder {
+ public:
+ using Representation = std::pair<absl::string_view, absl::string_view>;
+ using Representations = std::vector<Representation>;
+
+ // Callers may provide a HeaderListener to be informed of header name-value
+ // pairs processed by this encoder.
+ using HeaderListener =
+ quiche::MultiUseCallback<void(absl::string_view, absl::string_view)>;
+
+ // An indexing policy should return true if the provided header name-value
+ // pair should be inserted into the HPACK dynamic table.
+ using IndexingPolicy =
+ quiche::MultiUseCallback<bool(absl::string_view, absl::string_view)>;
+
+ HpackEncoder();
+ HpackEncoder(const HpackEncoder&) = delete;
+ HpackEncoder& operator=(const HpackEncoder&) = delete;
+ ~HpackEncoder();
+
+ // Encodes and returns the given header set as a string.
+ std::string EncodeHeaderBlock(const Http2HeaderBlock& header_set);
+
+ class QUICHE_EXPORT ProgressiveEncoder {
+ public:
+ virtual ~ProgressiveEncoder() {}
+
+ // Returns true iff more remains to encode.
+ virtual bool HasNext() const = 0;
+
+ // Encodes and returns up to max_encoded_bytes of the current header block.
+ virtual std::string Next(size_t max_encoded_bytes) = 0;
+ };
+
+ // Returns a ProgressiveEncoder which must be outlived by both the given
+ // Http2HeaderBlock and this object.
+ std::unique_ptr<ProgressiveEncoder> EncodeHeaderSet(
+ const Http2HeaderBlock& header_set);
+ // Returns a ProgressiveEncoder which must be outlived by this HpackEncoder.
+ // The encoder will not attempt to split any \0-delimited values in
+ // |representations|. If such splitting is desired, it must be performed by
+ // the caller when constructing the list of representations.
+ std::unique_ptr<ProgressiveEncoder> EncodeRepresentations(
+ const Representations& representations);
+
+ // Called upon a change to SETTINGS_HEADER_TABLE_SIZE. Specifically, this
+ // is to be called after receiving (and sending an acknowledgement for) a
+ // SETTINGS_HEADER_TABLE_SIZE update from the remote decoding endpoint.
+ void ApplyHeaderTableSizeSetting(size_t size_setting);
+
+ // TODO(birenroy): Rename this GetDynamicTableCapacity().
+ size_t CurrentHeaderTableSizeSetting() const {
+ return header_table_.settings_size_bound();
+ }
+
+ // This HpackEncoder will use |policy| to determine whether to insert header
+ // name-value pairs into the dynamic table.
+ void SetIndexingPolicy(IndexingPolicy policy) {
+ should_index_ = std::move(policy);
+ }
+
+ // |listener| will be invoked for each header name-value pair processed by
+ // this encoder.
+ void SetHeaderListener(HeaderListener listener) {
+ listener_ = std::move(listener);
+ }
+
+ void DisableCompression() { enable_compression_ = false; }
+
+ // Disables the deconstruction of Cookie header values into individual
+ // components, as described in
+ // https://httpwg.org/specs/rfc9113.html#CompressCookie. The deconstructed
+ // representation can cause problems for some HTTP/2 endpoints.
+ void DisableCookieCrumbling() { crumble_cookies_ = false; }
+
+ // Returns the current dynamic table size, including the 32 bytes per entry
+ // overhead mentioned in RFC 7541 section 4.1.
+ size_t GetDynamicTableSize() const { return header_table_.size(); }
+
+ private:
+ friend class test::HpackEncoderPeer;
+
+ class RepresentationIterator;
+ class Encoderator;
+
+ // Encodes a sequence of header name-value pairs as a single header block.
+ std::string EncodeRepresentations(RepresentationIterator* iter);
+
+ // Emits a static/dynamic indexed representation (Section 7.1).
+ void EmitIndex(size_t index);
+
+ // Emits a literal representation (Section 7.2).
+ void EmitIndexedLiteral(const Representation& representation);
+ void EmitNonIndexedLiteral(const Representation& representation,
+ bool enable_compression);
+ void EmitLiteral(const Representation& representation);
+
+ // Emits a Huffman or identity string (whichever is smaller).
+ void EmitString(absl::string_view str);
+
+ // Emits the current dynamic table size if the table size was recently
+ // updated and we have not yet emitted it (Section 6.3).
+ void MaybeEmitTableSize();
+
+ // Crumbles a cookie header into ";" delimited crumbs.
+ static void CookieToCrumbs(const Representation& cookie,
+ Representations* crumbs_out);
+
+ // Crumbles other header field values at \0 delimiters.
+ static void DecomposeRepresentation(const Representation& header_field,
+ Representations* out);
+
+ HpackHeaderTable header_table_;
+ HpackOutputStream output_stream_;
+
+ size_t min_table_size_setting_received_;
+ HeaderListener listener_;
+ IndexingPolicy should_index_;
+ bool enable_compression_;
+ bool should_emit_table_size_;
+ bool crumble_cookies_;
+};
+
+} // namespace spdy
+
+#endif // QUICHE_HTTP2_HPACK_HPACK_ENCODER_H_
diff --git a/quiche/spdy/core/hpack/hpack_encoder_test.cc b/quiche/http2/hpack/hpack_encoder_test.cc
similarity index 98%
rename from quiche/spdy/core/hpack/hpack_encoder_test.cc
rename to quiche/http2/hpack/hpack_encoder_test.cc
index 2d09358..48373e9 100644
--- a/quiche/spdy/core/hpack/hpack_encoder_test.cc
+++ b/quiche/http2/hpack/hpack_encoder_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include <cstddef>
#include <cstdint>
@@ -12,16 +12,16 @@
#include <vector>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include "quiche/http2/hpack/huffman/hpack_huffman_encoder.h"
#include "quiche/http2/test_tools/http2_random.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/platform/api/quiche_test.h"
#include "quiche/common/quiche_simple_arena.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
#include "quiche/spdy/core/http2_header_block.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_entry.cc b/quiche/http2/hpack/hpack_entry.cc
similarity index 94%
rename from quiche/spdy/core/hpack/hpack_entry.cc
rename to quiche/http2/hpack/hpack_entry.cc
index 365b623..bfdd9fa 100644
--- a/quiche/spdy/core/hpack/hpack_entry.cc
+++ b/quiche/http2/hpack/hpack_entry.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_entry.h"
#include <cstddef>
#include <string>
diff --git a/quiche/spdy/core/hpack/hpack_entry.h b/quiche/http2/hpack/hpack_entry.h
similarity index 94%
rename from quiche/spdy/core/hpack/hpack_entry.h
rename to quiche/http2/hpack/hpack_entry.h
index b84e0da..67749e9 100644
--- a/quiche/spdy/core/hpack/hpack_entry.h
+++ b/quiche/http2/hpack/hpack_entry.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_ENTRY_H_
-#define QUICHE_SPDY_CORE_HPACK_HPACK_ENTRY_H_
+#ifndef QUICHE_HTTP2_HPACK_HPACK_ENTRY_H_
+#define QUICHE_HTTP2_HPACK_HPACK_ENTRY_H_
#include <cstddef>
#include <string>
@@ -77,4 +77,4 @@
} // namespace spdy
-#endif // QUICHE_SPDY_CORE_HPACK_HPACK_ENTRY_H_
+#endif // QUICHE_HTTP2_HPACK_HPACK_ENTRY_H_
diff --git a/quiche/spdy/core/hpack/hpack_entry_test.cc b/quiche/http2/hpack/hpack_entry_test.cc
similarity index 96%
rename from quiche/spdy/core/hpack/hpack_entry_test.cc
rename to quiche/http2/hpack/hpack_entry_test.cc
index faf7786..e147987 100644
--- a/quiche/spdy/core/hpack/hpack_entry_test.cc
+++ b/quiche/http2/hpack/hpack_entry_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_entry.h"
#include "absl/hash/hash.h"
#include "quiche/common/platform/api/quiche_test.h"
diff --git a/quiche/spdy/core/hpack/hpack_header_table.cc b/quiche/http2/hpack/hpack_header_table.cc
similarity index 96%
rename from quiche/spdy/core/hpack/hpack_header_table.cc
rename to quiche/http2/hpack/hpack_header_table.cc
index 6deb280..0fbcc6e 100644
--- a/quiche/spdy/core/hpack/hpack_header_table.cc
+++ b/quiche/http2/hpack/hpack_header_table.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
#include <algorithm>
#include <cstddef>
@@ -11,10 +11,10 @@
#include <utility>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_header_table.h b/quiche/http2/hpack/hpack_header_table.h
similarity index 96%
rename from quiche/spdy/core/hpack/hpack_header_table.h
rename to quiche/http2/hpack/hpack_header_table.h
index ab1842e..b6c2385 100644
--- a/quiche/spdy/core/hpack/hpack_header_table.h
+++ b/quiche/http2/hpack/hpack_header_table.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_
-#define QUICHE_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_
+#ifndef QUICHE_HTTP2_HPACK_HPACK_HEADER_TABLE_H_
+#define QUICHE_HTTP2_HPACK_HPACK_HEADER_TABLE_H_
#include <cstddef>
#include <memory>
@@ -11,9 +11,9 @@
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_entry.h"
#include "quiche/common/platform/api/quiche_export.h"
#include "quiche/common/quiche_circular_deque.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
// All section references below are to http://tools.ietf.org/html/rfc7541.
@@ -146,4 +146,4 @@
} // namespace spdy
-#endif // QUICHE_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_
+#endif // QUICHE_HTTP2_HPACK_HPACK_HEADER_TABLE_H_
diff --git a/quiche/spdy/core/hpack/hpack_header_table_test.cc b/quiche/http2/hpack/hpack_header_table_test.cc
similarity index 98%
rename from quiche/spdy/core/hpack/hpack_header_table_test.cc
rename to quiche/http2/hpack/hpack_header_table_test.cc
index 9cc3608..f634309 100644
--- a/quiche/spdy/core/hpack/hpack_header_table_test.cc
+++ b/quiche/http2/hpack/hpack_header_table_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
#include <algorithm>
#include <cstddef>
@@ -11,10 +11,10 @@
#include <vector>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include "quiche/common/platform/api/quiche_test.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_output_stream.cc b/quiche/http2/hpack/hpack_output_stream.cc
similarity index 96%
rename from quiche/spdy/core/hpack/hpack_output_stream.cc
rename to quiche/http2/hpack/hpack_output_stream.cc
index f41007e..aa50c0a 100644
--- a/quiche/spdy/core/hpack/hpack_output_stream.cc
+++ b/quiche/http2/hpack/hpack_output_stream.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
#include <cstddef>
#include <cstdint>
@@ -10,8 +10,8 @@
#include <utility>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_output_stream.h b/quiche/http2/hpack/hpack_output_stream.h
similarity index 91%
rename from quiche/spdy/core/hpack/hpack_output_stream.h
rename to quiche/http2/hpack/hpack_output_stream.h
index 7640f80..c56ba87 100644
--- a/quiche/spdy/core/hpack/hpack_output_stream.h
+++ b/quiche/http2/hpack/hpack_output_stream.h
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_OUTPUT_STREAM_H_
-#define QUICHE_SPDY_CORE_HPACK_HPACK_OUTPUT_STREAM_H_
+#ifndef QUICHE_HTTP2_HPACK_HPACK_OUTPUT_STREAM_H_
+#define QUICHE_HTTP2_HPACK_HPACK_OUTPUT_STREAM_H_
#include <cstddef>
#include <cstdint>
#include <string>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
#include "quiche/common/platform/api/quiche_export.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
// All section references below are to
// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
@@ -72,4 +72,4 @@
} // namespace spdy
-#endif // QUICHE_SPDY_CORE_HPACK_HPACK_OUTPUT_STREAM_H_
+#endif // QUICHE_HTTP2_HPACK_HPACK_OUTPUT_STREAM_H_
diff --git a/quiche/spdy/core/hpack/hpack_output_stream_test.cc b/quiche/http2/hpack/hpack_output_stream_test.cc
similarity index 99%
rename from quiche/spdy/core/hpack/hpack_output_stream_test.cc
rename to quiche/http2/hpack/hpack_output_stream_test.cc
index a756eee..c5a764a 100644
--- a/quiche/spdy/core/hpack/hpack_output_stream_test.cc
+++ b/quiche/http2/hpack/hpack_output_stream_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
#include <cstdint>
#include <string>
diff --git a/quiche/spdy/core/hpack/hpack_static_table.cc b/quiche/http2/hpack/hpack_static_table.cc
similarity index 90%
rename from quiche/spdy/core/hpack/hpack_static_table.cc
rename to quiche/http2/hpack/hpack_static_table.cc
index 30a88af..8a0d912 100644
--- a/quiche/spdy/core/hpack/hpack_static_table.cc
+++ b/quiche/http2/hpack/hpack_static_table.cc
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include <cstddef>
#include <string>
#include <utility>
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_entry.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
namespace spdy {
diff --git a/quiche/spdy/core/hpack/hpack_static_table.h b/quiche/http2/hpack/hpack_static_table.h
similarity index 88%
rename from quiche/spdy/core/hpack/hpack_static_table.h
rename to quiche/http2/hpack/hpack_static_table.h
index 5973367..0280d37 100644
--- a/quiche/spdy/core/hpack/hpack_static_table.h
+++ b/quiche/http2/hpack/hpack_static_table.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
-#define QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
+#ifndef QUICHE_HTTP2_HPACK_HPACK_STATIC_TABLE_H_
+#define QUICHE_HTTP2_HPACK_HPACK_STATIC_TABLE_H_
#include <cstddef>
+#include "quiche/http2/hpack/hpack_header_table.h"
#include "quiche/common/platform/api/quiche_export.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
namespace spdy {
@@ -55,4 +55,4 @@
} // namespace spdy
-#endif // QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
+#endif // QUICHE_HTTP2_HPACK_HPACK_STATIC_TABLE_H_
diff --git a/quiche/spdy/core/hpack/hpack_static_table_test.cc b/quiche/http2/hpack/hpack_static_table_test.cc
similarity index 91%
rename from quiche/spdy/core/hpack/hpack_static_table_test.cc
rename to quiche/http2/hpack/hpack_static_table_test.cc
index ddb6787..3863b06 100644
--- a/quiche/spdy/core/hpack/hpack_static_table_test.cc
+++ b/quiche/http2/hpack/hpack_static_table_test.cc
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include <set>
#include <vector>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
#include "quiche/common/platform/api/quiche_test.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
namespace spdy {
diff --git a/quiche/quic/core/qpack/qpack_header_table.h b/quiche/quic/core/qpack/qpack_header_table.h
index 748c11b..a57b478 100644
--- a/quiche/quic/core/qpack/qpack_header_table.h
+++ b/quiche/quic/core/qpack/qpack_header_table.h
@@ -9,10 +9,10 @@
#include <deque>
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_entry.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
#include "quiche/quic/platform/api/quic_export.h"
#include "quiche/common/quiche_circular_deque.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
namespace quic {
diff --git a/quiche/quic/core/qpack/qpack_header_table_test.cc b/quiche/quic/core/qpack/qpack_header_table_test.cc
index c4331a6..826273a 100644
--- a/quiche/quic/core/qpack/qpack_header_table_test.cc
+++ b/quiche/quic/core/qpack/qpack_header_table_test.cc
@@ -10,9 +10,9 @@
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_entry.h"
#include "quiche/quic/core/qpack/qpack_static_table.h"
#include "quiche/quic/platform/api/quic_test.h"
-#include "quiche/spdy/core/hpack/hpack_entry.h"
namespace quic {
namespace test {
diff --git a/quiche/quic/core/qpack/qpack_static_table.h b/quiche/quic/core/qpack/qpack_static_table.h
index 89ec254..f3a1596 100644
--- a/quiche/quic/core/qpack/qpack_static_table.h
+++ b/quiche/quic/core/qpack/qpack_static_table.h
@@ -7,9 +7,9 @@
#include <vector>
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_static_table.h"
#include "quiche/quic/platform/api/quic_export.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_static_table.h"
namespace quic {
diff --git a/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc b/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc
index 00309d0..fbd11ad 100644
--- a/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc
+++ b/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc
@@ -20,15 +20,15 @@
#include "quiche/http2/hpack/decoder/hpack_decoder.h"
#include "quiche/http2/hpack/decoder/hpack_decoder_state.h"
#include "quiche/http2/hpack/decoder/hpack_decoder_tables.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
+#include "quiche/http2/hpack/hpack_output_stream.h"
#include "quiche/http2/hpack/http2_hpack_constants.h"
#include "quiche/http2/test_tools/hpack_block_builder.h"
#include "quiche/http2/test_tools/http2_random.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/platform/api/quiche_test.h"
#include "quiche/common/quiche_text_utils.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
#include "quiche/spdy/core/http2_header_block.h"
#include "quiche/spdy/core/recording_headers_handler.h"
diff --git a/quiche/spdy/core/hpack/hpack_encoder.h b/quiche/spdy/core/hpack/hpack_encoder.h
index 35007c6..8e746c8 100644
--- a/quiche/spdy/core/hpack/hpack_encoder.h
+++ b/quiche/spdy/core/hpack/hpack_encoder.h
@@ -5,152 +5,8 @@
#ifndef QUICHE_SPDY_CORE_HPACK_HPACK_ENCODER_H_
#define QUICHE_SPDY_CORE_HPACK_HPACK_ENCODER_H_
-#include <stddef.h>
+#include "quiche/http2/hpack/hpack_encoder.h"
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "absl/strings/string_view.h"
-#include "quiche/common/platform/api/quiche_export.h"
-#include "quiche/common/quiche_callbacks.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
-#include "quiche/spdy/core/hpack/hpack_output_stream.h"
-#include "quiche/spdy/core/http2_header_block.h"
-
-// An HpackEncoder encodes header sets as outlined in
-// http://tools.ietf.org/html/rfc7541.
-
-namespace spdy {
-
-namespace test {
-class HpackEncoderPeer;
-} // namespace test
-
-class QUICHE_EXPORT HpackEncoder {
- public:
- using Representation = std::pair<absl::string_view, absl::string_view>;
- using Representations = std::vector<Representation>;
-
- // Callers may provide a HeaderListener to be informed of header name-value
- // pairs processed by this encoder.
- using HeaderListener =
- quiche::MultiUseCallback<void(absl::string_view, absl::string_view)>;
-
- // An indexing policy should return true if the provided header name-value
- // pair should be inserted into the HPACK dynamic table.
- using IndexingPolicy =
- quiche::MultiUseCallback<bool(absl::string_view, absl::string_view)>;
-
- HpackEncoder();
- HpackEncoder(const HpackEncoder&) = delete;
- HpackEncoder& operator=(const HpackEncoder&) = delete;
- ~HpackEncoder();
-
- // Encodes and returns the given header set as a string.
- std::string EncodeHeaderBlock(const Http2HeaderBlock& header_set);
-
- class QUICHE_EXPORT ProgressiveEncoder {
- public:
- virtual ~ProgressiveEncoder() {}
-
- // Returns true iff more remains to encode.
- virtual bool HasNext() const = 0;
-
- // Encodes and returns up to max_encoded_bytes of the current header block.
- virtual std::string Next(size_t max_encoded_bytes) = 0;
- };
-
- // Returns a ProgressiveEncoder which must be outlived by both the given
- // Http2HeaderBlock and this object.
- std::unique_ptr<ProgressiveEncoder> EncodeHeaderSet(
- const Http2HeaderBlock& header_set);
- // Returns a ProgressiveEncoder which must be outlived by this HpackEncoder.
- // The encoder will not attempt to split any \0-delimited values in
- // |representations|. If such splitting is desired, it must be performed by
- // the caller when constructing the list of representations.
- std::unique_ptr<ProgressiveEncoder> EncodeRepresentations(
- const Representations& representations);
-
- // Called upon a change to SETTINGS_HEADER_TABLE_SIZE. Specifically, this
- // is to be called after receiving (and sending an acknowledgement for) a
- // SETTINGS_HEADER_TABLE_SIZE update from the remote decoding endpoint.
- void ApplyHeaderTableSizeSetting(size_t size_setting);
-
- // TODO(birenroy): Rename this GetDynamicTableCapacity().
- size_t CurrentHeaderTableSizeSetting() const {
- return header_table_.settings_size_bound();
- }
-
- // This HpackEncoder will use |policy| to determine whether to insert header
- // name-value pairs into the dynamic table.
- void SetIndexingPolicy(IndexingPolicy policy) {
- should_index_ = std::move(policy);
- }
-
- // |listener| will be invoked for each header name-value pair processed by
- // this encoder.
- void SetHeaderListener(HeaderListener listener) {
- listener_ = std::move(listener);
- }
-
- void DisableCompression() { enable_compression_ = false; }
-
- // Disables the deconstruction of Cookie header values into individual
- // components, as described in
- // https://httpwg.org/specs/rfc9113.html#CompressCookie. The deconstructed
- // representation can cause problems for some HTTP/2 endpoints.
- void DisableCookieCrumbling() { crumble_cookies_ = false; }
-
- // Returns the current dynamic table size, including the 32 bytes per entry
- // overhead mentioned in RFC 7541 section 4.1.
- size_t GetDynamicTableSize() const { return header_table_.size(); }
-
- private:
- friend class test::HpackEncoderPeer;
-
- class RepresentationIterator;
- class Encoderator;
-
- // Encodes a sequence of header name-value pairs as a single header block.
- std::string EncodeRepresentations(RepresentationIterator* iter);
-
- // Emits a static/dynamic indexed representation (Section 7.1).
- void EmitIndex(size_t index);
-
- // Emits a literal representation (Section 7.2).
- void EmitIndexedLiteral(const Representation& representation);
- void EmitNonIndexedLiteral(const Representation& representation,
- bool enable_compression);
- void EmitLiteral(const Representation& representation);
-
- // Emits a Huffman or identity string (whichever is smaller).
- void EmitString(absl::string_view str);
-
- // Emits the current dynamic table size if the table size was recently
- // updated and we have not yet emitted it (Section 6.3).
- void MaybeEmitTableSize();
-
- // Crumbles a cookie header into ";" delimited crumbs.
- static void CookieToCrumbs(const Representation& cookie,
- Representations* crumbs_out);
-
- // Crumbles other header field values at \0 delimiters.
- static void DecomposeRepresentation(const Representation& header_field,
- Representations* out);
-
- HpackHeaderTable header_table_;
- HpackOutputStream output_stream_;
-
- size_t min_table_size_setting_received_;
- HeaderListener listener_;
- IndexingPolicy should_index_;
- bool enable_compression_;
- bool should_emit_table_size_;
- bool crumble_cookies_;
-};
-
-} // namespace spdy
+// TODO(b/234438854): remove this file once Envoy has migrated to the new target
#endif // QUICHE_SPDY_CORE_HPACK_HPACK_ENCODER_H_
diff --git a/quiche/spdy/core/hpack/hpack_round_trip_test.cc b/quiche/spdy/core/hpack/hpack_round_trip_test.cc
index 4c044d5..db39349 100644
--- a/quiche/spdy/core/hpack/hpack_round_trip_test.cc
+++ b/quiche/spdy/core/hpack/hpack_round_trip_test.cc
@@ -8,10 +8,10 @@
#include <string>
#include <vector>
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/http2/test_tools/http2_random.h"
#include "quiche/common/platform/api/quiche_test.h"
#include "quiche/spdy/core/hpack/hpack_decoder_adapter.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
#include "quiche/spdy/core/http2_header_block.h"
#include "quiche/spdy/core/recording_headers_handler.h"
diff --git a/quiche/spdy/core/http2_frame_decoder_adapter.cc b/quiche/spdy/core/http2_frame_decoder_adapter.cc
index 3896ebd..f8c7052 100644
--- a/quiche/spdy/core/http2_frame_decoder_adapter.cc
+++ b/quiche/spdy/core/http2_frame_decoder_adapter.cc
@@ -21,13 +21,13 @@
#include "quiche/http2/decoder/decode_status.h"
#include "quiche/http2/decoder/http2_frame_decoder.h"
#include "quiche/http2/hpack/decoder/hpack_decoding_error.h"
+#include "quiche/http2/hpack/hpack_header_table.h"
#include "quiche/http2/http2_constants.h"
#include "quiche/http2/http2_structures.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/quiche_endian.h"
#include "quiche/spdy/core/hpack/hpack_decoder_adapter.h"
-#include "quiche/spdy/core/hpack/hpack_header_table.h"
#include "quiche/spdy/core/spdy_alt_svc_wire_format.h"
#include "quiche/spdy/core/spdy_headers_handler_interface.h"
#include "quiche/spdy/core/spdy_protocol.h"
diff --git a/quiche/spdy/core/spdy_framer.cc b/quiche/spdy/core/spdy_framer.cc
index 654641a..097aaac 100644
--- a/quiche/spdy/core/spdy_framer.cc
+++ b/quiche/spdy/core/spdy_framer.cc
@@ -13,10 +13,10 @@
#include "absl/base/attributes.h"
#include "absl/memory/memory.h"
+#include "quiche/http2/hpack/hpack_constants.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
-#include "quiche/spdy/core/hpack/hpack_constants.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
#include "quiche/spdy/core/http2_header_block.h"
#include "quiche/spdy/core/spdy_alt_svc_wire_format.h"
#include "quiche/spdy/core/spdy_frame_builder.h"
diff --git a/quiche/spdy/core/spdy_framer.h b/quiche/spdy/core/spdy_framer.h
index de755e6..c9f8200 100644
--- a/quiche/spdy/core/spdy_framer.h
+++ b/quiche/spdy/core/spdy_framer.h
@@ -12,8 +12,8 @@
#include <string>
#include <utility>
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/common/platform/api/quiche_export.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
#include "quiche/spdy/core/spdy_protocol.h"
#include "quiche/spdy/core/zero_copy_output_buffer.h"
diff --git a/quiche/spdy/core/spdy_framer_test.cc b/quiche/spdy/core/spdy_framer_test.cc
index 9c52ada..7dc0a1a 100644
--- a/quiche/spdy/core/spdy_framer_test.cc
+++ b/quiche/spdy/core/spdy_framer_test.cc
@@ -18,11 +18,11 @@
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
+#include "quiche/http2/hpack/hpack_encoder.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/platform/api/quiche_test.h"
#include "quiche/common/quiche_text_utils.h"
#include "quiche/spdy/core/array_output_buffer.h"
-#include "quiche/spdy/core/hpack/hpack_encoder.h"
#include "quiche/spdy/core/http2_frame_decoder_adapter.h"
#include "quiche/spdy/core/http2_header_block.h"
#include "quiche/spdy/core/recording_headers_handler.h"