Factors out a utility method to convert an absl::Span<Header> into a spdy::SpdyHeaderBlock.
PiperOrigin-RevId: 374274256
diff --git a/http2/adapter/oghttp2_util.cc b/http2/adapter/oghttp2_util.cc
new file mode 100644
index 0000000..3ed13dc
--- /dev/null
+++ b/http2/adapter/oghttp2_util.cc
@@ -0,0 +1,17 @@
+#include "http2/adapter/oghttp2_util.h"
+
+namespace http2 {
+namespace adapter {
+
+spdy::SpdyHeaderBlock ToHeaderBlock(absl::Span<const Header> headers) {
+ spdy::SpdyHeaderBlock block;
+ for (const Header& header : headers) {
+ absl::string_view name = GetStringView(header.first).first;
+ absl::string_view value = GetStringView(header.second).first;
+ block[name] = value;
+ }
+ return block;
+}
+
+} // namespace adapter
+} // namespace http2
diff --git a/http2/adapter/oghttp2_util.h b/http2/adapter/oghttp2_util.h
new file mode 100644
index 0000000..e222c96
--- /dev/null
+++ b/http2/adapter/oghttp2_util.h
@@ -0,0 +1,16 @@
+#ifndef QUICHE_HTTP2_ADAPTER_OGHTTP2_UTIL_H_
+#define QUICHE_HTTP2_ADAPTER_OGHTTP2_UTIL_H_
+
+#include "absl/types/span.h"
+#include "http2/adapter/http2_protocol.h"
+#include "spdy/core/spdy_header_block.h"
+
+namespace http2 {
+namespace adapter {
+
+spdy::SpdyHeaderBlock ToHeaderBlock(absl::Span<const Header> headers);
+
+} // namespace adapter
+} // namespace http2
+
+#endif // QUICHE_HTTP2_ADAPTER_OGHTTP2_UTIL_H_
diff --git a/http2/adapter/test_frame_sequence.cc b/http2/adapter/test_frame_sequence.cc
index a4d3806..7be368e 100644
--- a/http2/adapter/test_frame_sequence.cc
+++ b/http2/adapter/test_frame_sequence.cc
@@ -1,6 +1,7 @@
#include "http2/adapter/test_frame_sequence.h"
#include "http2/adapter/http2_util.h"
+#include "http2/adapter/oghttp2_util.h"
#include "spdy/core/spdy_framer.h"
namespace http2 {
@@ -104,13 +105,7 @@
TestFrameSequence& TestFrameSequence::Headers(Http2StreamId stream_id,
absl::Span<const Header> headers,
bool fin) {
- spdy::SpdyHeaderBlock block;
- for (const Header& header : headers) {
- 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);
+ return Headers(stream_id, ToHeaderBlock(headers), fin);
}
TestFrameSequence& TestFrameSequence::WindowUpdate(Http2StreamId stream_id,