Updates the representation of a header name or value.
This representation can either be a string_view reference to a static string, or a std::string. This will make it easier to incorporate zero-copy header handling into the adapter interface.
PiperOrigin-RevId: 374236816
diff --git a/http2/adapter/test_frame_sequence.cc b/http2/adapter/test_frame_sequence.cc
index 46d33b6..a4d3806 100644
--- a/http2/adapter/test_frame_sequence.cc
+++ b/http2/adapter/test_frame_sequence.cc
@@ -7,6 +7,15 @@
namespace adapter {
namespace test {
+std::vector<const Header> ToHeaders(
+ absl::Span<const std::pair<absl::string_view, absl::string_view>> headers) {
+ std::vector<const Header> out;
+ for (auto [name, value] : headers) {
+ out.push_back(std::make_pair(HeaderRep(name), HeaderRep(value)));
+ }
+ return out;
+}
+
TestFrameSequence& TestFrameSequence::ClientPreface() {
preface_ = spdy::kHttp2ConnectionHeaderPrefix;
frames_.push_back(absl::make_unique<spdy::SpdySettingsIR>());
@@ -75,6 +84,13 @@
return *this;
}
+TestFrameSequence& TestFrameSequence::Headers(
+ Http2StreamId stream_id,
+ absl::Span<const std::pair<absl::string_view, absl::string_view>> headers,
+ bool fin) {
+ return Headers(stream_id, ToHeaders(headers), fin);
+}
+
TestFrameSequence& TestFrameSequence::Headers(Http2StreamId stream_id,
spdy::Http2HeaderBlock block,
bool fin) {
@@ -90,7 +106,9 @@
bool fin) {
spdy::SpdyHeaderBlock block;
for (const Header& header : headers) {
- block[header.first] = header.second;
+ absl::string_view name = GetStringView(header.first).first;
+ absl::string_view value = GetStringView(header.second).first;
+ block[name] = value;
}
return Headers(stream_id, std::move(block), fin);
}