Replace deprecated version of absl::HexStringToBytes in quic/core/http tests
Replaces the deprecated version of absl::HexStringToBytes that returns std::string with the version that returns bool and populates a passed in std::string. This CL is not expected to introduce any changes in functionality other than now verifying that the call to absl::HexStringToBytes was successful.
This allows the Chrome build of QUICHE to build without the `-Wno-deprecated-declarations` clang flag.
PiperOrigin-RevId: 614722292
diff --git a/quiche/quic/core/http/http_decoder_test.cc b/quiche/quic/core/http/http_decoder_test.cc
index f0af1c5..4fe08c0 100644
--- a/quiche/quic/core/http/http_decoder_test.cc
+++ b/quiche/quic/core/http/http_decoder_test.cc
@@ -5,6 +5,7 @@
#include "quiche/quic/core/http/http_decoder.h"
#include <memory>
+#include <string>
#include <utility>
#include "absl/base/macros.h"
@@ -151,10 +152,12 @@
TEST_F(HttpDecoderTest, CancelPush) {
InSequence s;
- std::string input = absl::HexStringToBytes(
- "03" // type (CANCEL_PUSH)
- "01" // length
- "01"); // Push Id
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("03" // type (CANCEL_PUSH)
+ "01" // length
+ "01", // Push Id
+ &input));
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(1u, ProcessInput(input));
@@ -164,11 +167,14 @@
TEST_F(HttpDecoderTest, PushPromiseFrame) {
InSequence s;
- std::string input =
- absl::StrCat(absl::HexStringToBytes("05" // type (PUSH PROMISE)
- "08" // length
- "1f"), // push id 31
- "Headers"); // headers
+ std::string push_promise_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("05" // type (PUSH PROMISE)
+ "08" // length
+ "1f", // push id 31
+ &push_promise_bytes));
+ std::string input = absl::StrCat(push_promise_bytes,
+ "Headers"); // headers
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(1u, ProcessInput(input));
@@ -178,10 +184,12 @@
TEST_F(HttpDecoderTest, MaxPushId) {
InSequence s;
- std::string input = absl::HexStringToBytes(
- "0D" // type (MAX_PUSH_ID)
- "01" // length
- "01"); // Push Id
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("0D" // type (MAX_PUSH_ID)
+ "01" // length
+ "01", // Push Id
+ &input));
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnMaxPushIdFrame()).WillOnce(Return(false));
@@ -204,7 +212,8 @@
TEST_F(HttpDecoderTest, SettingsFrame) {
InSequence s;
- std::string input = absl::HexStringToBytes(
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes(
"04" // type (SETTINGS)
"07" // length
"01" // identifier (SETTINGS_QPACK_MAX_TABLE_CAPACITY)
@@ -212,7 +221,8 @@
"06" // identifier (SETTINGS_MAX_HEADER_LIST_SIZE)
"05" // content
"4100" // identifier, encoded on 2 bytes (0x40), value is 256 (0x100)
- "04"); // content
+ "04", // content
+ &input));
SettingsFrame frame;
frame.values[1] = 2;
@@ -284,13 +294,15 @@
}
TEST_F(HttpDecoderTest, DuplicateSettingsIdentifier) {
- std::string input = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "04" // length
- "01" // identifier
- "01" // content
- "01" // identifier
- "02"); // content
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "04" // length
+ "01" // identifier
+ "01" // content
+ "01" // identifier
+ "02", // content
+ &input));
EXPECT_CALL(visitor_, OnSettingsFrameStart(2));
EXPECT_CALL(visitor_, OnError(&decoder_));
@@ -304,9 +316,13 @@
TEST_F(HttpDecoderTest, DataFrame) {
InSequence s;
- std::string input = absl::StrCat(absl::HexStringToBytes("00" // type (DATA)
- "05"), // length
- "Data!"); // data
+ std::string type_and_length_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // type (DATA)
+ "05", // length
+ &type_and_length_bytes));
+ std::string input = absl::StrCat(type_and_length_bytes,
+ "Data!"); // data
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)).WillOnce(Return(false));
@@ -403,10 +419,12 @@
TEST_F(HttpDecoderTest, GoAway) {
InSequence s;
- std::string input = absl::HexStringToBytes(
- "07" // type (GOAWAY)
- "01" // length
- "01"); // ID
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("07" // type (GOAWAY)
+ "01" // length
+ "01", // ID
+ &input));
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnGoAwayFrame(GoAwayFrame({1})))
@@ -430,10 +448,13 @@
TEST_F(HttpDecoderTest, HeadersFrame) {
InSequence s;
- std::string input =
- absl::StrCat(absl::HexStringToBytes("01" // type (HEADERS)
- "07"), // length
- "Headers"); // headers
+ std::string type_and_length_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("01" // type (HEADERS)
+ "07", // length
+ &type_and_length_bytes));
+ std::string input = absl::StrCat(type_and_length_bytes,
+ "Headers"); // headers
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)).WillOnce(Return(false));
@@ -481,10 +502,13 @@
return;
}
InSequence s;
- std::string input =
- absl::StrCat(absl::HexStringToBytes("404d" // 2 byte type (METADATA)
- "08"), // length
- "Metadata"); // headers
+ std::string type_and_length_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("404d" // 2 byte type (METADATA)
+ "08", // length
+ &type_and_length_bytes));
+ std::string input = absl::StrCat(type_and_length_bytes,
+ "Metadata"); // headers
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnMetadataFrameStart(3, 8)).WillOnce(Return(false));
@@ -530,9 +554,11 @@
TEST_F(HttpDecoderTest, EmptyDataFrame) {
InSequence s;
- std::string input = absl::HexStringToBytes(
- "00" // type (DATA)
- "00"); // length
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // type (DATA)
+ "00", // length
+ &input));
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnDataFrameStart(2, 0)).WillOnce(Return(false));
@@ -560,9 +586,11 @@
TEST_F(HttpDecoderTest, EmptyHeadersFrame) {
InSequence s;
- std::string input = absl::HexStringToBytes(
- "01" // type (HEADERS)
- "00"); // length
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("01" // type (HEADERS)
+ "00", // length
+ &input));
// Visitor pauses processing.
EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 0)).WillOnce(Return(false));
@@ -589,9 +617,11 @@
}
TEST_F(HttpDecoderTest, GoawayWithOverlyLargePayload) {
- std::string input = absl::HexStringToBytes(
- "07" // type (GOAWAY)
- "10"); // length exceeding the maximum possible length for GOAWAY frame
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes(
+ "07" // type (GOAWAY)
+ "10", // length exceeding the maximum possible length for GOAWAY frame
+ &input));
// Process all data at once.
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(2u, ProcessInput(input));
@@ -600,10 +630,12 @@
}
TEST_F(HttpDecoderTest, MaxPushIdWithOverlyLargePayload) {
- std::string input = absl::HexStringToBytes(
- "0d" // type (MAX_PUSH_ID)
- "10"); // length exceeding the maximum possible length for MAX_PUSH_ID
- // frame
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("0d" // type (MAX_PUSH_ID)
+ "10", // length exceeding the maximum possible
+ // length for MAX_PUSH_ID frame
+ &input));
// Process all data at once.
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(2u, ProcessInput(input));
@@ -623,7 +655,7 @@
::testing::NiceMock<MockHttpDecoderVisitor> visitor;
HttpDecoder decoder(&visitor);
QuicDataWriter writer(max_input_length, input);
- ASSERT_TRUE(writer.WriteVarInt62(frame_type)); // frame type.
+ ASSERT_TRUE(writer.WriteVarInt62(frame_type)); // frame type.
ASSERT_TRUE(
writer.WriteVarInt62(quiche::kVarInt62MaxValue)); // frame length.
ASSERT_TRUE(writer.WriteUInt8(0x00)); // one byte of payload.
@@ -647,10 +679,12 @@
}
TEST_F(HttpDecoderTest, Http2Frame) {
- std::string input = absl::HexStringToBytes(
- "06" // PING in HTTP/2 but not supported in HTTP/3.
- "05" // length
- "15"); // random payload
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes(
+ "06" // PING in HTTP/2 but not supported in HTTP/3.
+ "05" // length
+ "15", // random payload
+ &input));
// Process the full frame.
EXPECT_CALL(visitor_, OnError(&decoder_));
@@ -662,13 +696,19 @@
TEST_F(HttpDecoderTest, HeadersPausedThenData) {
InSequence s;
- std::string input =
- absl::StrCat(absl::HexStringToBytes("01" // type (HEADERS)
- "07"), // length
- "Headers", // headers
- absl::HexStringToBytes("00" // type (DATA)
- "05"), // length
- "Data!"); // data
+ std::string headers_type_and_length_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("01" // type (HEADERS)
+ "07", // length,
+ &headers_type_and_length_bytes));
+ std::string headers = absl::StrCat(headers_type_and_length_bytes, "Headers");
+ std::string data_type_and_length_bytes;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // type (DATA)
+ "05", // length
+ &data_type_and_length_bytes));
+ std::string data = absl::StrCat(data_type_and_length_bytes, "Data!");
+ std::string input = absl::StrCat(headers, data);
// Visitor pauses processing, maybe because header decompression is blocked.
EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7));
@@ -775,9 +815,11 @@
}
TEST_F(HttpDecoderTest, EmptySettingsFrame) {
- std::string input = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "00"); // frame length
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "00", // frame length
+ &input));
EXPECT_CALL(visitor_, OnSettingsFrameStart(2));
@@ -790,9 +832,11 @@
}
TEST_F(HttpDecoderTest, EmptyGoAwayFrame) {
- std::string input = absl::HexStringToBytes(
- "07" // type (GOAWAY)
- "00"); // frame length
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("07" // type (GOAWAY)
+ "00", // frame length
+ &input));
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(input.size(), ProcessInput(input));
@@ -801,9 +845,11 @@
}
TEST_F(HttpDecoderTest, EmptyMaxPushIdFrame) {
- std::string input = absl::HexStringToBytes(
- "0d" // type (MAX_PUSH_ID)
- "00"); // frame length
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("0d" // type (MAX_PUSH_ID)
+ "00", // frame length
+ &input));
EXPECT_CALL(visitor_, OnError(&decoder_));
EXPECT_EQ(input.size(), ProcessInput(input));
@@ -828,10 +874,12 @@
const QuicByteCount header_length = 2;
const QuicByteCount payload_length = 3;
InSequence s;
- std::string input = absl::HexStringToBytes(
- "0f" // type (obsolete PRIORITY_UPDATE)
- "03" // length
- "666f6f"); // payload "foo"
+ std::string input;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("0f" // type (obsolete PRIORITY_UPDATE)
+ "03" // length
+ "666f6f", // payload "foo"
+ &input));
// Process frame as a whole.
EXPECT_CALL(visitor_,
@@ -859,10 +907,12 @@
TEST_F(HttpDecoderTest, PriorityUpdateFrame) {
InSequence s;
- std::string input1 = absl::HexStringToBytes(
- "800f0700" // type (PRIORITY_UPDATE)
- "01" // length
- "03"); // prioritized element id
+ std::string input1;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("800f0700" // type (PRIORITY_UPDATE)
+ "01" // length
+ "03", // prioritized element id
+ &input1));
PriorityUpdateFrame priority_update1;
priority_update1.prioritized_element_id = 0x03;
@@ -896,11 +946,13 @@
EXPECT_THAT(decoder_.error(), IsQuicNoError());
EXPECT_EQ("", decoder_.error_detail());
- std::string input2 = absl::HexStringToBytes(
- "800f0700" // type (PRIORITY_UPDATE)
- "04" // length
- "05" // prioritized element id
- "666f6f"); // priority field value: "foo"
+ std::string input2;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("800f0700" // type (PRIORITY_UPDATE)
+ "04" // length
+ "05" // prioritized element id
+ "666f6f", // priority field value: "foo"
+ &input2));
PriorityUpdateFrame priority_update2;
priority_update2.prioritized_element_id = 0x05;
@@ -936,8 +988,9 @@
}
TEST_F(HttpDecoderTest, CorruptPriorityUpdateFrame) {
- std::string payload =
- absl::HexStringToBytes("4005"); // prioritized element id
+ std::string payload;
+ ASSERT_TRUE(absl::HexStringToBytes("4005", // prioritized element id
+ &payload));
struct {
size_t payload_length;
const char* const error_message;
@@ -947,8 +1000,9 @@
};
for (const auto& test_data : kTestData) {
- std::string input =
- absl::HexStringToBytes("800f0700"); // type PRIORITY_UPDATE
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes("800f0700", // type PRIORITY_UPDATE
+ &input));
input.push_back(test_data.payload_length);
size_t header_length = input.size();
input.append(payload.data(), test_data.payload_length);
@@ -967,9 +1021,11 @@
TEST_F(HttpDecoderTest, AcceptChFrame) {
InSequence s;
- std::string input1 = absl::HexStringToBytes(
- "4089" // type (ACCEPT_CH)
- "00"); // length
+ std::string input1;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("4089" // type (ACCEPT_CH)
+ "00", // length
+ &input1));
AcceptChFrame accept_ch1;
@@ -1001,13 +1057,15 @@
EXPECT_THAT(decoder_.error(), IsQuicNoError());
EXPECT_EQ("", decoder_.error_detail());
- std::string input2 = absl::HexStringToBytes(
- "4089" // type (ACCEPT_CH)
- "08" // length
- "03" // length of origin
- "666f6f" // origin "foo"
- "03" // length of value
- "626172"); // value "bar"
+ std::string input2;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("4089" // type (ACCEPT_CH)
+ "08" // length
+ "03" // length of origin
+ "666f6f" // origin "foo"
+ "03" // length of value
+ "626172", // value "bar"
+ &input2));
AcceptChFrame accept_ch2;
accept_ch2.entries.push_back({"foo", "bar"});
@@ -1044,7 +1102,8 @@
InSequence s;
// Unknown frame of type 0x41 and length 0x104.
- std::string input = absl::HexStringToBytes("40414104");
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes("40414104", &input));
EXPECT_CALL(visitor_, OnUnknownFrameStart(0x41, input.size(), 0x104));
EXPECT_EQ(ProcessInput(input), input.size());
}
@@ -1055,7 +1114,8 @@
decoder.EnableWebTransportStreamParsing();
// WebTransport stream for session ID 0x104, with four bytes of extra data.
- std::string input = absl::HexStringToBytes("40414104ffffffff");
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes("40414104ffffffff", &input));
EXPECT_CALL(visitor, OnWebTransportStreamFrameType(4, 0x104));
QuicByteCount bytes = decoder.ProcessInput(input.data(), input.size());
EXPECT_EQ(bytes, 4u);
@@ -1066,7 +1126,8 @@
HttpDecoder decoder(&visitor);
decoder.EnableWebTransportStreamParsing();
- std::string input = absl::HexStringToBytes("404100");
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes("404100", &input));
EXPECT_CALL(visitor, OnWebTransportStreamFrameType(_, _));
decoder.ProcessInput(input.data(), input.size());
@@ -1079,7 +1140,8 @@
}
TEST_F(HttpDecoderTest, DecodeSettings) {
- std::string input = absl::HexStringToBytes(
+ std::string input;
+ ASSERT_TRUE(absl::HexStringToBytes(
"04" // type (SETTINGS)
"07" // length
"01" // identifier (SETTINGS_QPACK_MAX_TABLE_CAPACITY)
@@ -1087,7 +1149,8 @@
"06" // identifier (SETTINGS_MAX_HEADER_LIST_SIZE)
"05" // content
"4100" // identifier, encoded on 2 bytes (0x40), value is 256 (0x100)
- "04"); // content
+ "04", // content
+ &input));
SettingsFrame frame;
frame.values[1] = 2;
@@ -1099,18 +1162,20 @@
EXPECT_EQ(frame, out);
// non-settings frame.
- input = absl::HexStringToBytes(
- "0D" // type (MAX_PUSH_ID)
- "01" // length
- "01"); // Push Id
+ ASSERT_TRUE(
+ absl::HexStringToBytes("0D" // type (MAX_PUSH_ID)
+ "01" // length
+ "01", // Push Id
+ &input));
EXPECT_FALSE(HttpDecoder::DecodeSettings(input.data(), input.size(), &out));
// Corrupt SETTINGS.
- input = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "01" // length
- "42"); // First byte of setting identifier, indicating a 2-byte varint62.
+ ASSERT_TRUE(absl::HexStringToBytes(
+ "04" // type (SETTINGS)
+ "01" // length
+ "42", // First byte of setting identifier, indicating a 2-byte varint62.
+ &input));
EXPECT_FALSE(HttpDecoder::DecodeSettings(input.data(), input.size(), &out));
}
diff --git a/quiche/quic/core/http/quic_receive_control_stream_test.cc b/quiche/quic/core/http/quic_receive_control_stream_test.cc
index d448fe1..e335d82 100644
--- a/quiche/quic/core/http/quic_receive_control_stream_test.cc
+++ b/quiche/quic/core/http/quic_receive_control_stream_test.cc
@@ -4,6 +4,8 @@
#include "quiche/quic/core/http/quic_receive_control_stream.h"
+#include <string>
+
#include "absl/memory/memory.h"
#include "absl/strings/escaping.h"
#include "absl/strings/string_view.h"
@@ -284,10 +286,12 @@
}
TEST_P(QuicReceiveControlStreamTest, PushPromiseOnControlStreamShouldClose) {
- std::string push_promise_frame = absl::HexStringToBytes(
- "05" // PUSH_PROMISE
- "01" // length
- "00"); // push ID
+ std::string push_promise_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("05" // PUSH_PROMISE
+ "01" // length
+ "00", // push ID
+ &push_promise_frame));
QuicStreamFrame frame(receive_control_stream_->id(), false, 1,
push_promise_frame);
EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_FRAME_ERROR, _, _))
@@ -315,10 +319,12 @@
EXPECT_EQ(offset, NumBytesConsumed());
// Receive unknown frame.
- std::string unknown_frame = absl::HexStringToBytes(
- "21" // reserved frame type
- "03" // payload length
- "666f6f"); // payload "foo"
+ std::string unknown_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("21" // reserved frame type
+ "03" // payload length
+ "666f6f", // payload "foo"
+ &unknown_frame));
receive_control_stream_->OnStreamFrame(QuicStreamFrame(
receive_control_stream_->id(), /* fin = */ false, offset, unknown_frame));
@@ -344,10 +350,12 @@
offset += settings_frame.length();
// Receive unknown frame.
- std::string unknown_frame = absl::HexStringToBytes(
- "21" // reserved frame type
- "03" // payload length
- "666f6f"); // payload "foo"
+ std::string unknown_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("21" // reserved frame type
+ "03" // payload length
+ "666f6f", // payload "foo"
+ &unknown_frame));
EXPECT_CALL(debug_visitor, OnUnknownFrameReceived(id, /* frame_type = */ 0x21,
/* payload_length = */ 3));
@@ -356,10 +364,12 @@
}
TEST_P(QuicReceiveControlStreamTest, CancelPushFrameBeforeSettings) {
- std::string cancel_push_frame = absl::HexStringToBytes(
- "03" // type CANCEL_PUSH
- "01" // payload length
- "01"); // push ID
+ std::string cancel_push_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("03" // type CANCEL_PUSH
+ "01" // payload length
+ "01", // push ID
+ &cancel_push_frame));
EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_FRAME_ERROR,
"CANCEL_PUSH frame received.", _))
@@ -374,9 +384,11 @@
}
TEST_P(QuicReceiveControlStreamTest, AcceptChFrameBeforeSettings) {
- std::string accept_ch_frame = absl::HexStringToBytes(
- "4089" // type (ACCEPT_CH)
- "00"); // length
+ std::string accept_ch_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("4089" // type (ACCEPT_CH)
+ "00", // length
+ &accept_ch_frame));
if (perspective() == Perspective::IS_SERVER) {
EXPECT_CALL(*connection_,
@@ -418,9 +430,11 @@
offset += settings_frame.length();
// Receive ACCEPT_CH frame.
- std::string accept_ch_frame = absl::HexStringToBytes(
- "4089" // type (ACCEPT_CH)
- "00"); // length
+ std::string accept_ch_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("4089" // type (ACCEPT_CH)
+ "00", // length
+ &accept_ch_frame));
if (perspective() == Perspective::IS_CLIENT) {
EXPECT_CALL(debug_visitor, OnAcceptChFrameReceived(_));
@@ -440,10 +454,12 @@
}
TEST_P(QuicReceiveControlStreamTest, UnknownFrameBeforeSettings) {
- std::string unknown_frame = absl::HexStringToBytes(
- "21" // reserved frame type
- "03" // payload length
- "666f6f"); // payload "foo"
+ std::string unknown_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("21" // reserved frame type
+ "03" // payload length
+ "666f6f", // payload "foo"
+ &unknown_frame));
EXPECT_CALL(*connection_,
CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME,
diff --git a/quiche/quic/core/http/quic_send_control_stream_test.cc b/quiche/quic/core/http/quic_send_control_stream_test.cc
index e83e46d..922daa1 100644
--- a/quiche/quic/core/http/quic_send_control_stream_test.cc
+++ b/quiche/quic/core/http/quic_send_control_stream_test.cc
@@ -4,6 +4,7 @@
#include "quiche/quic/core/http/quic_send_control_stream.h"
+#include <string>
#include <utility>
#include "absl/strings/escaping.h"
@@ -115,85 +116,90 @@
Initialize();
testing::InSequence s;
- std::string expected_write_data = absl::HexStringToBytes(
- "00" // stream type: control stream
- "04" // frame type: SETTINGS frame
- "0b" // frame length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "40ff" // 255
- "06" // SETTINGS_MAX_HEADER_LIST_SIZE
- "4400" // 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "10" // 16
- "4040" // 0x40 as the reserved settings id
- "14" // 20
- "4040" // 0x40 as the reserved frame type
- "01" // 1 byte frame length
- "61"); // payload "a"
+ std::string expected_write_data;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // stream type: control stream
+ "04" // frame type: SETTINGS frame
+ "0b" // frame length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "40ff" // 255
+ "06" // SETTINGS_MAX_HEADER_LIST_SIZE
+ "4400" // 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "10" // 16
+ "4040" // 0x40 as the reserved settings id
+ "14" // 20
+ "4040" // 0x40 as the reserved frame type
+ "01" // 1 byte frame length
+ "61", // payload "a"
+ &expected_write_data));
if (perspective() == Perspective::IS_CLIENT &&
QuicSpdySessionPeer::LocalHttpDatagramSupport(&session_) !=
HttpDatagramSupport::kNone) {
- expected_write_data = absl::HexStringToBytes(
- "00" // stream type: control stream
- "04" // frame type: SETTINGS frame
- "0d" // frame length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "40ff" // 255
- "06" // SETTINGS_MAX_HEADER_LIST_SIZE
- "4400" // 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "10" // 16
- "33" // SETTINGS_H3_DATAGRAM
- "01" // 1
- "4040" // 0x40 as the reserved settings id
- "14" // 20
- "4040" // 0x40 as the reserved frame type
- "01" // 1 byte frame length
- "61"); // payload "a"
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // stream type: control stream
+ "04" // frame type: SETTINGS frame
+ "0d" // frame length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "40ff" // 255
+ "06" // SETTINGS_MAX_HEADER_LIST_SIZE
+ "4400" // 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "10" // 16
+ "33" // SETTINGS_H3_DATAGRAM
+ "01" // 1
+ "4040" // 0x40 as the reserved settings id
+ "14" // 20
+ "4040" // 0x40 as the reserved frame type
+ "01" // 1 byte frame length
+ "61", // payload "a"
+ &expected_write_data));
}
if (perspective() == Perspective::IS_SERVER &&
QuicSpdySessionPeer::LocalHttpDatagramSupport(&session_) ==
HttpDatagramSupport::kNone) {
- expected_write_data = absl::HexStringToBytes(
- "00" // stream type: control stream
- "04" // frame type: SETTINGS frame
- "0d" // frame length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "40ff" // 255
- "06" // SETTINGS_MAX_HEADER_LIST_SIZE
- "4400" // 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "10" // 16
- "08" // SETTINGS_ENABLE_CONNECT_PROTOCOL
- "01" // 1
- "4040" // 0x40 as the reserved settings id
- "14" // 20
- "4040" // 0x40 as the reserved frame type
- "01" // 1 byte frame length
- "61"); // payload "a"
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // stream type: control stream
+ "04" // frame type: SETTINGS frame
+ "0d" // frame length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "40ff" // 255
+ "06" // SETTINGS_MAX_HEADER_LIST_SIZE
+ "4400" // 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "10" // 16
+ "08" // SETTINGS_ENABLE_CONNECT_PROTOCOL
+ "01" // 1
+ "4040" // 0x40 as the reserved settings id
+ "14" // 20
+ "4040" // 0x40 as the reserved frame type
+ "01" // 1 byte frame length
+ "61", // payload "a"
+ &expected_write_data));
}
if (perspective() == Perspective::IS_SERVER &&
QuicSpdySessionPeer::LocalHttpDatagramSupport(&session_) !=
HttpDatagramSupport::kNone) {
- expected_write_data = absl::HexStringToBytes(
- "00" // stream type: control stream
- "04" // frame type: SETTINGS frame
- "0f" // frame length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "40ff" // 255
- "06" // SETTINGS_MAX_HEADER_LIST_SIZE
- "4400" // 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "10" // 16
- "08" // SETTINGS_ENABLE_CONNECT_PROTOCOL
- "01" // 1
- "33" // SETTINGS_H3_DATAGRAM
- "01" // 1
- "4040" // 0x40 as the reserved settings id
- "14" // 20
- "4040" // 0x40 as the reserved frame type
- "01" // 1 byte frame length
- "61"); // payload "a"
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // stream type: control stream
+ "04" // frame type: SETTINGS frame
+ "0f" // frame length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "40ff" // 255
+ "06" // SETTINGS_MAX_HEADER_LIST_SIZE
+ "4400" // 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "10" // 16
+ "08" // SETTINGS_ENABLE_CONNECT_PROTOCOL
+ "01" // 1
+ "33" // SETTINGS_H3_DATAGRAM
+ "01" // 1
+ "4040" // 0x40 as the reserved settings id
+ "14" // 20
+ "4040" // 0x40 as the reserved frame type
+ "01" // 1 byte frame length
+ "61", // payload "a"
+ &expected_write_data));
}
char buffer[1000] = {};
diff --git a/quiche/quic/core/http/quic_spdy_session_test.cc b/quiche/quic/core/http/quic_spdy_session_test.cc
index cf4fffd..2dace2d 100644
--- a/quiche/quic/core/http/quic_spdy_session_test.cc
+++ b/quiche/quic/core/http/quic_spdy_session_test.cc
@@ -1996,7 +1996,8 @@
EXPECT_EQ(0u, QuicSessionPeer::GetNumOpenDynamicStreams(&*session_));
// Push unidirectional stream is type 0x01.
- std::string frame_type1 = absl::HexStringToBytes("01");
+ std::string frame_type1;
+ ASSERT_TRUE(absl::HexStringToBytes("01", &frame_type1));
QuicStreamId stream_id1 =
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
EXPECT_CALL(*connection_,
@@ -2016,9 +2017,11 @@
EXPECT_EQ(0u, QuicSessionPeer::GetNumOpenDynamicStreams(&*session_));
// Push unidirectional stream is type 0x01.
- std::string frame_type = absl::HexStringToBytes("01");
+ std::string frame_type;
+ ASSERT_TRUE(absl::HexStringToBytes("01", &frame_type));
// The first field of a push stream is the Push ID.
- std::string push_id = absl::HexStringToBytes("4000");
+ std::string push_id;
+ ASSERT_TRUE(absl::HexStringToBytes("4000", &push_id));
QuicStreamId stream_id =
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
@@ -2746,7 +2749,8 @@
TestStream* stream = session_->CreateIncomingStream(stream_id);
// HEADERS frame referencing first dynamic table entry.
- std::string headers_frame_payload = absl::HexStringToBytes("020080");
+ std::string headers_frame_payload;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &headers_frame_payload));
std::string headers_frame_header =
HttpEncoder::SerializeHeadersFrameHeader(headers_frame_payload.length());
std::string headers_frame =
@@ -2778,7 +2782,8 @@
TestStream* stream = session_->CreateIncomingStream(stream_id);
// HEADERS frame referencing first dynamic table entry.
- std::string headers_frame_payload = absl::HexStringToBytes("020080");
+ std::string headers_frame_payload;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &headers_frame_payload));
std::string headers_frame_header =
HttpEncoder::SerializeHeadersFrameHeader(headers_frame_payload.length());
std::string headers_frame =
@@ -2809,7 +2814,8 @@
// Payload consists of two bytes. The first byte is an unknown unidirectional
// stream type. The second one would be the type of a push stream, but it
// must not be interpreted as stream type.
- std::string payload = absl::HexStringToBytes("3f01");
+ std::string payload;
+ ASSERT_TRUE(absl::HexStringToBytes("3f01", &payload));
QuicStreamFrame frame(stream_id, /* fin = */ false, /* offset = */ 0,
payload);
@@ -2857,7 +2863,8 @@
// Payload consists of two bytes. The first byte is an unknown unidirectional
// stream type. The second one would be the type of a push stream, but it
// must not be interpreted as stream type.
- std::string payload = absl::HexStringToBytes("3f01");
+ std::string payload;
+ ASSERT_TRUE(absl::HexStringToBytes("3f01", &payload));
QuicStreamFrame frame(stream_id, /* fin = */ false, /* offset = */ 0,
payload);
@@ -2896,7 +2903,8 @@
ASSERT_TRUE(session_->UsesPendingStreamForFrame(STREAM_FRAME, stream_id));
// Payload is the first byte of a two byte varint encoding.
- std::string payload = absl::HexStringToBytes("40");
+ std::string payload;
+ ASSERT_TRUE(absl::HexStringToBytes("40", &payload));
QuicStreamFrame frame(stream_id, /* fin = */ false, /* offset = */ 0,
payload);
@@ -2926,7 +2934,8 @@
ASSERT_TRUE(session_->UsesPendingStreamForFrame(STREAM_FRAME, stream_id));
// Payload is the first byte of a two byte varint encoding with a FIN.
- std::string payload = absl::HexStringToBytes("40");
+ std::string payload;
+ ASSERT_TRUE(absl::HexStringToBytes("40", &payload));
QuicStreamFrame frame(stream_id, /* fin = */ true, /* offset = */ 0, payload);
session_->OnStreamFrame(frame);
@@ -3015,9 +3024,11 @@
}
CompleteHandshake();
- std::string data = absl::HexStringToBytes(
- "02" // Encoder stream.
- "00"); // Duplicate entry 0, but no entries exist.
+ std::string data;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("02" // Encoder stream.
+ "00", // Duplicate entry 0, but no entries exist.
+ &data));
QuicStreamId stream_id =
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
@@ -3038,9 +3049,11 @@
}
CompleteHandshake();
- std::string data = absl::HexStringToBytes(
- "03" // Decoder stream.
- "00"); // Insert Count Increment with forbidden increment value of zero.
+ std::string data;
+ ASSERT_TRUE(absl::HexStringToBytes(
+ "03" // Decoder stream.
+ "00", // Insert Count Increment with forbidden increment value of zero.
+ &data));
QuicStreamId stream_id =
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
@@ -3123,10 +3136,12 @@
EXPECT_CALL(debug_visitor, OnSettingsFrameReceived(_));
session_->OnStreamFrame(data2);
- std::string cancel_push_frame = absl::HexStringToBytes(
- "03" // CANCEL_PUSH
- "01" // length
- "00"); // push ID
+ std::string cancel_push_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("03" // CANCEL_PUSH
+ "01" // length
+ "00", // push ID
+ &cancel_push_frame));
QuicStreamFrame data3(receive_control_stream_id, /* fin = */ false, offset,
cancel_push_frame);
EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_FRAME_ERROR,
@@ -3188,14 +3203,16 @@
// Index 126 does not exist (static table has 61 entries and dynamic table is
// empty).
- std::string headers_frame = absl::HexStringToBytes(
- "000006" // length
- "01" // type
- "24" // flags: PRIORITY | END_HEADERS
- "00000005" // stream_id
- "00000000" // stream dependency
- "10" // weight
- "fe"); // payload: reference to index 126.
+ std::string headers_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("000006" // length
+ "01" // type
+ "24" // flags: PRIORITY | END_HEADERS
+ "00000005" // stream_id
+ "00000000" // stream dependency
+ "10" // weight
+ "fe", // payload: reference to index 126.
+ &headers_frame));
QuicStreamId headers_stream_id =
QuicUtils::GetHeadersStreamId(transport_version());
QuicStreamFrame data(headers_stream_id, false, 0, headers_frame);
@@ -3333,10 +3350,12 @@
EXPECT_CALL(debug_visitor, OnSettingsFrameReceived(_));
session_->OnStreamFrame(data2);
- std::string cancel_push_frame = absl::HexStringToBytes(
- "03" // CANCEL_PUSH
- "01" // length
- "00"); // push ID
+ std::string cancel_push_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("03" // CANCEL_PUSH
+ "01" // length
+ "00", // push ID
+ &cancel_push_frame));
QuicStreamFrame data3(receive_control_stream_id, /* fin = */ false, offset,
cancel_push_frame);
EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_FRAME_ERROR,
@@ -3487,13 +3506,15 @@
StrictMock<MockHttp3DebugVisitor> debug_visitor;
session_->set_debug_visitor(&debug_visitor);
- std::string serialized_accept_ch_frame = absl::HexStringToBytes(
- "4089" // type (ACCEPT_CH)
- "08" // length
- "03" // length of origin
- "666f6f" // origin "foo"
- "03" // length of value
- "626172"); // value "bar"
+ std::string serialized_accept_ch_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("4089" // type (ACCEPT_CH)
+ "08" // length
+ "03" // length of origin
+ "666f6f" // origin "foo"
+ "03" // length of value
+ "626172", // value "bar"
+ &serialized_accept_ch_frame));
AcceptChFrame expected_accept_ch_frame{{{"foo", "bar"}}};
EXPECT_CALL(debug_visitor,
@@ -3511,10 +3532,12 @@
return;
}
- std::string forbidden_frame = absl::HexStringToBytes(
- "00" // type (DATA)
- "03" // length
- "66666f"); // "foo"
+ std::string forbidden_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00" // type (DATA)
+ "03" // length
+ "66666f", // "foo"
+ &forbidden_frame));
auto error = session_->OnAlpsData(
reinterpret_cast<const uint8_t*>(forbidden_frame.data()),
@@ -3529,9 +3552,11 @@
return;
}
- std::string incomplete_frame = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "03"); // non-zero length but empty payload
+ std::string incomplete_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "03", // non-zero length but empty payload
+ &incomplete_frame));
auto error = session_->OnAlpsData(
reinterpret_cast<const uint8_t*>(incomplete_frame.data()),
@@ -3556,13 +3581,15 @@
StrictMock<MockHttp3DebugVisitor> debug_visitor;
session_->set_debug_visitor(&debug_visitor);
- std::string serialized_settings_frame1 = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "05" // length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "4400" // 0x0400 = 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "20"); // 0x20 = 32
+ std::string serialized_settings_frame1;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "05" // length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "4400" // 0x0400 = 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "20", // 0x20 = 32
+ &serialized_settings_frame1));
SettingsFrame expected_settings_frame1{
{{SETTINGS_QPACK_MAX_TABLE_CAPACITY, 1024},
@@ -3582,7 +3609,8 @@
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
EXPECT_CALL(debug_visitor, OnPeerControlStreamCreated(control_stream_id));
- std::string stream_type = absl::HexStringToBytes("00");
+ std::string stream_type;
+ ASSERT_TRUE(absl::HexStringToBytes("00", &stream_type));
session_->OnStreamFrame(QuicStreamFrame(control_stream_id, /* fin = */ false,
/* offset = */ 0, stream_type));
@@ -3594,13 +3622,15 @@
{{SETTINGS_QPACK_MAX_TABLE_CAPACITY, 1024},
{SETTINGS_QPACK_BLOCKED_STREAMS, 48}}};
EXPECT_CALL(debug_visitor, OnSettingsFrameReceived(expected_settings_frame2));
- std::string serialized_settings_frame2 = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "05" // length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "4400" // 0x0400 = 1024
- "07" // SETTINGS_QPACK_BLOCKED_STREAMS
- "30"); // 0x30 = 48
+ std::string serialized_settings_frame2;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "05" // length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "4400" // 0x0400 = 1024
+ "07" // SETTINGS_QPACK_BLOCKED_STREAMS
+ "30", // 0x30 = 48
+ &serialized_settings_frame2));
session_->OnStreamFrame(QuicStreamFrame(control_stream_id, /* fin = */ false,
/* offset = */ stream_type.length(),
serialized_settings_frame2));
@@ -3622,11 +3652,13 @@
QpackEncoder* qpack_encoder = session_->qpack_encoder();
EXPECT_EQ(0u, qpack_encoder->MaximumDynamicTableCapacity());
- std::string serialized_settings_frame1 = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "03" // length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "4400"); // 0x0400 = 1024
+ std::string serialized_settings_frame1;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "03" // length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "4400", // 0x0400 = 1024
+ &serialized_settings_frame1));
auto error = session_->OnAlpsData(
reinterpret_cast<const uint8_t*>(serialized_settings_frame1.data()),
@@ -3638,7 +3670,8 @@
const QuicStreamId control_stream_id =
GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0);
- std::string stream_type = absl::HexStringToBytes("00");
+ std::string stream_type;
+ ASSERT_TRUE(absl::HexStringToBytes("00", &stream_type));
session_->OnStreamFrame(QuicStreamFrame(control_stream_id, /* fin = */ false,
/* offset = */ 0, stream_type));
@@ -3648,11 +3681,13 @@
"Server sent an SETTINGS_QPACK_MAX_TABLE_CAPACITY: "
"32 while current value is: 1024",
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET));
- std::string serialized_settings_frame2 = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "02" // length
- "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
- "20"); // 0x20 = 32
+ std::string serialized_settings_frame2;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "02" // length
+ "01" // SETTINGS_QPACK_MAX_TABLE_CAPACITY
+ "20", // 0x20 = 32
+ &serialized_settings_frame2));
session_->OnStreamFrame(QuicStreamFrame(control_stream_id, /* fin = */ false,
/* offset = */ stream_type.length(),
serialized_settings_frame2));
@@ -3664,11 +3699,13 @@
return;
}
- std::string banned_frame = absl::HexStringToBytes(
- "04" // type (SETTINGS)
- "00" // length
- "04" // type (SETTINGS)
- "00"); // length
+ std::string banned_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("04" // type (SETTINGS)
+ "00" // length
+ "04" // type (SETTINGS)
+ "00", // length
+ &banned_frame));
auto error = session_->OnAlpsData(
reinterpret_cast<const uint8_t*>(banned_frame.data()),
@@ -4134,25 +4171,33 @@
QuicStreamSendBufferPeer::CurrentWriteSlice(&send_buffer)->slice;
absl::string_view stream_data(slice.data(), slice.length());
- EXPECT_EQ(absl::HexStringToBytes(
- "000009" // frame length
- "01" // frame type HEADERS
- "25"), // flags END_STREAM | END_HEADERS | PRIORITY
- stream_data.substr(0, 5));
+ std::string expected_stream_data_1;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("000009" // frame length
+ "01" // frame type HEADERS
+ "25", // flags END_STREAM | END_HEADERS | PRIORITY
+ &expected_stream_data_1));
+ EXPECT_EQ(expected_stream_data_1, stream_data.substr(0, 5));
stream_data.remove_prefix(5);
// Ignore stream ID as it might differ between QUIC versions.
stream_data.remove_prefix(4);
- EXPECT_EQ(absl::HexStringToBytes("00000000" // stream dependency
- "92"), // stream weight
- stream_data.substr(0, 5));
+ std::string expected_stream_data_2;
+
+ ASSERT_TRUE(
+ absl::HexStringToBytes("00000000" // stream dependency
+ "92", // stream weight
+ &expected_stream_data_2));
+ EXPECT_EQ(expected_stream_data_2, stream_data.substr(0, 5));
stream_data.remove_prefix(5);
- EXPECT_EQ(absl::HexStringToBytes(
- "3fe17f" // Dynamic Table Size Update to 16384
- "82"), // Indexed Header Field Representation with index 2
- stream_data);
+ std::string expected_stream_data_3;
+ ASSERT_TRUE(absl::HexStringToBytes(
+ "3fe17f" // Dynamic Table Size Update to 16384
+ "82", // Indexed Header Field Representation with index 2
+ &expected_stream_data_3));
+ EXPECT_EQ(expected_stream_data_3, stream_data);
}
class QuicSpdySessionTestServerNoExtendedConnect
diff --git a/quiche/quic/core/http/quic_spdy_stream_test.cc b/quiche/quic/core/http/quic_spdy_stream_test.cc
index 4f6ca18..73d145f 100644
--- a/quiche/quic/core/http/quic_spdy_stream_test.cc
+++ b/quiche/quic/core/http/quic_spdy_stream_test.cc
@@ -747,7 +747,8 @@
Initialize(kShouldProcessData);
// PUSH_PROMISE frame is considered invalid.
- std::string invalid_http3_frame = absl::HexStringToBytes("0500");
+ std::string invalid_http3_frame;
+ ASSERT_TRUE(absl::HexStringToBytes("0500", &invalid_http3_frame));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, invalid_http3_frame);
@@ -763,7 +764,8 @@
Initialize(kShouldProcessData);
// SETTINGS frame with empty payload.
- std::string settings = absl::HexStringToBytes("0400");
+ std::string settings;
+ ASSERT_TRUE(absl::HexStringToBytes("0400", &settings));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, settings);
@@ -2155,8 +2157,9 @@
connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
// Random bad headers.
- std::string headers =
- HeadersFrame(absl::HexStringToBytes("00002a94e7036261"));
+ std::string headers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("00002a94e7036261", &headers_bytes));
+ std::string headers = HeadersFrame(headers_bytes);
std::string data = DataFrame(kDataFramePayload);
std::string stream_frame_payload = absl::StrCat(headers, data);
@@ -2223,7 +2226,9 @@
// Invalid headers: Required Insert Count is zero, but the header block
// contains a dynamic table reference.
- std::string headers = HeadersFrame(absl::HexStringToBytes("000080"));
+ std::string headers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("000080", &headers_bytes));
+ std::string headers = HeadersFrame(headers_bytes);
QuicStreamFrame frame(stream_->id(), false, 0, headers);
stream_->OnStreamFrame(frame);
}
@@ -2246,7 +2251,8 @@
session_->qpack_decoder()->OnInsertWithoutNameReference("foo", "bar");
// HEADERS frame referencing first dynamic table entry.
- std::string encoded_headers = absl::HexStringToBytes("020080");
+ std::string encoded_headers;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &encoded_headers));
std::string headers = HeadersFrame(encoded_headers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_headers.length()));
@@ -2282,7 +2288,8 @@
session_->qpack_decoder()->OnInsertWithoutNameReference("trailing", "foobar");
// Trailing HEADERS frame referencing second dynamic table entry.
- std::string encoded_trailers = absl::HexStringToBytes("030080");
+ std::string encoded_trailers;
+ ASSERT_TRUE(absl::HexStringToBytes("030080", &encoded_trailers));
std::string trailers = HeadersFrame(encoded_trailers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_trailers.length()));
@@ -2317,7 +2324,8 @@
session_->set_debug_visitor(&debug_visitor);
// HEADERS frame referencing first dynamic table entry.
- std::string encoded_headers = absl::HexStringToBytes("020080");
+ std::string encoded_headers;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &encoded_headers));
std::string headers = HeadersFrame(encoded_headers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_headers.length()));
@@ -2357,7 +2365,8 @@
EXPECT_EQ(kDataFramePayload, stream_->data());
// Trailing HEADERS frame referencing second dynamic table entry.
- std::string encoded_trailers = absl::HexStringToBytes("030080");
+ std::string encoded_trailers;
+ ASSERT_TRUE(absl::HexStringToBytes("030080", &encoded_trailers));
std::string trailers = HeadersFrame(encoded_trailers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_trailers.length()));
@@ -2394,7 +2403,9 @@
// HEADERS frame only referencing entry with absolute index 0 but with
// Required Insert Count = 2, which is incorrect.
- std::string headers = HeadersFrame(absl::HexStringToBytes("030081"));
+ std::string headers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("030081", &headers_bytes));
+ std::string headers = HeadersFrame(headers_bytes);
stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), false, 0, headers));
// Even though entire header block is received and every referenced entry is
@@ -2426,7 +2437,9 @@
session_->qpack_decoder()->OnSetDynamicTableCapacity(1024);
// Relative index 2 is invalid because it is larger than or equal to the Base.
- std::string headers = HeadersFrame(absl::HexStringToBytes("020082"));
+ std::string headers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("020082", &headers_bytes));
+ std::string headers = HeadersFrame(headers_bytes);
stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), false, 0, headers));
// Decoding is blocked.
@@ -2454,7 +2467,9 @@
session_->qpack_decoder()->OnSetDynamicTableCapacity(1024);
// HEADERS frame referencing first dynamic table entry.
- std::string headers = HeadersFrame(absl::HexStringToBytes("020080"));
+ std::string headers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &headers_bytes));
+ std::string headers = HeadersFrame(headers_bytes);
stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), false, 0, headers));
// Decoding is blocked because dynamic table entry has not been received yet.
@@ -2489,7 +2504,9 @@
// Trailing HEADERS frame only referencing entry with absolute index 0 but
// with Required Insert Count = 2, which is incorrect.
- std::string trailers = HeadersFrame(absl::HexStringToBytes("030081"));
+ std::string trailers_bytes;
+ ASSERT_TRUE(absl::HexStringToBytes("030081", &trailers_bytes));
+ std::string trailers = HeadersFrame(trailers_bytes);
stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), true, /* offset = */
headers.length() + data.length(),
trailers));
@@ -2525,7 +2542,8 @@
session_->set_debug_visitor(&debug_visitor);
// HEADERS frame referencing first dynamic table entry.
- std::string encoded_headers = absl::HexStringToBytes("020080");
+ std::string encoded_headers;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &encoded_headers));
std::string headers = HeadersFrame(encoded_headers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_headers.length()));
@@ -2575,7 +2593,8 @@
session_->set_debug_visitor(&debug_visitor);
// HEADERS frame referencing first dynamic table entry.
- std::string encoded_headers = absl::HexStringToBytes("020080");
+ std::string encoded_headers;
+ ASSERT_TRUE(absl::HexStringToBytes("020080", &encoded_headers));
std::string headers = HeadersFrame(encoded_headers);
EXPECT_CALL(debug_visitor,
OnHeadersFrameReceived(stream_->id(), encoded_headers.length()));
@@ -3016,7 +3035,8 @@
Initialize(kShouldProcessData);
// SETTINGS frame with empty payload.
- std::string settings = absl::HexStringToBytes("0400");
+ std::string settings;
+ ASSERT_TRUE(absl::HexStringToBytes("0400", &settings));
// HEADERS frame.
// Since it arrives after a SETTINGS frame, it should never be read.
@@ -3224,8 +3244,9 @@
StrictMock<MockHttp3DebugVisitor> debug_visitor;
session_->set_debug_visitor(&debug_visitor);
- std::string webtransport_stream_frame =
- absl::HexStringToBytes("40410400000000");
+ std::string webtransport_stream_frame;
+ ASSERT_TRUE(
+ absl::HexStringToBytes("40410400000000", &webtransport_stream_frame));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, webtransport_stream_frame);
@@ -3247,7 +3268,8 @@
settings.values[SETTINGS_H3_DATAGRAM] = 1;
session_->OnSettingsFrame(settings);
- std::string webtransport_stream_frame = absl::HexStringToBytes("404110");
+ std::string webtransport_stream_frame;
+ ASSERT_TRUE(absl::HexStringToBytes("404110", &webtransport_stream_frame));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, webtransport_stream_frame);
@@ -3269,7 +3291,8 @@
settings.values[SETTINGS_H3_DATAGRAM] = 1;
session_->OnSettingsFrame(settings);
- std::string webtransport_stream_frame = absl::HexStringToBytes("2100404110");
+ std::string webtransport_stream_frame;
+ ASSERT_TRUE(absl::HexStringToBytes("2100404110", &webtransport_stream_frame));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, webtransport_stream_frame);
@@ -3291,7 +3314,8 @@
settings.values[SETTINGS_H3_DATAGRAM] = 1;
session_->OnSettingsFrame(settings);
- std::string webtransport_stream_frame = absl::HexStringToBytes("2100404110");
+ std::string webtransport_stream_frame;
+ ASSERT_TRUE(absl::HexStringToBytes("2100404110", &webtransport_stream_frame));
QuicStreamFrame stream_frame(stream_->id(), /* fin = */ false,
/* offset = */ 0, webtransport_stream_frame);