Remove PrioritizedElementType. This was always REQUEST_STREAM when parsing, because HttpDecoder ignores frame type 0xf0701. It was also always REQUEST_STREAM when serializing, because HttpEncoder::SerializePriorityUpdateFrame() called QUIC_BUG if it wasn't. PiperOrigin-RevId: 490319696
diff --git a/quiche/quic/core/http/http_decoder.cc b/quiche/quic/core/http/http_decoder.cc index c6be41e..5facad8 100644 --- a/quiche/quic/core/http/http_decoder.cc +++ b/quiche/quic/core/http/http_decoder.cc
@@ -616,8 +616,6 @@ bool HttpDecoder::ParsePriorityUpdateFrame(QuicDataReader* reader, PriorityUpdateFrame* frame) { - frame->prioritized_element_type = REQUEST_STREAM; - if (!reader->ReadVarInt62(&frame->prioritized_element_id)) { RaiseError(QUIC_HTTP_FRAME_ERROR, "Unable to read prioritized element id."); return false;
diff --git a/quiche/quic/core/http/http_decoder_test.cc b/quiche/quic/core/http/http_decoder_test.cc index c0a18ee..79544b3 100644 --- a/quiche/quic/core/http/http_decoder_test.cc +++ b/quiche/quic/core/http/http_decoder_test.cc
@@ -810,7 +810,6 @@ "03"); // prioritized element id PriorityUpdateFrame priority_update1; - priority_update1.prioritized_element_type = REQUEST_STREAM; priority_update1.prioritized_element_id = 0x03; // Visitor pauses processing. @@ -849,7 +848,6 @@ "666f6f"); // priority field value: "foo" PriorityUpdateFrame priority_update2; - priority_update2.prioritized_element_type = REQUEST_STREAM; priority_update2.prioritized_element_id = 0x05; priority_update2.priority_field_value = "foo";
diff --git a/quiche/quic/core/http/http_encoder.cc b/quiche/quic/core/http/http_encoder.cc index 66c8373..de40d4a 100644 --- a/quiche/quic/core/http/http_encoder.cc +++ b/quiche/quic/core/http/http_encoder.cc
@@ -133,12 +133,6 @@ std::string HttpEncoder::SerializePriorityUpdateFrame( const PriorityUpdateFrame& priority_update) { - if (priority_update.prioritized_element_type != REQUEST_STREAM) { - QUIC_BUG(quic_bug_10402_1) - << "PRIORITY_UPDATE for push streams not implemented"; - return {}; - } - QuicByteCount payload_length = QuicDataWriter::GetVarInt62Len(priority_update.prioritized_element_id) + priority_update.priority_field_value.size();
diff --git a/quiche/quic/core/http/http_encoder_test.cc b/quiche/quic/core/http/http_encoder_test.cc index be05203..6487992 100644 --- a/quiche/quic/core/http/http_encoder_test.cc +++ b/quiche/quic/core/http/http_encoder_test.cc
@@ -65,17 +65,31 @@ TEST(HttpEncoderTest, SerializePriorityUpdateFrame) { PriorityUpdateFrame priority_update1; - priority_update1.prioritized_element_type = REQUEST_STREAM; priority_update1.prioritized_element_id = 0x03; uint8_t output1[] = {0x80, 0x0f, 0x07, 0x00, // type (PRIORITY_UPDATE) 0x01, // length 0x03}; // prioritized element id - std::string frame = + std::string frame1 = HttpEncoder::SerializePriorityUpdateFrame(priority_update1); quiche::test::CompareCharArraysWithHexError( - "PRIORITY_UPDATE", frame.data(), frame.length(), + "PRIORITY_UPDATE", frame1.data(), frame1.length(), reinterpret_cast<char*>(output1), ABSL_ARRAYSIZE(output1)); + + PriorityUpdateFrame priority_update2; + priority_update2.prioritized_element_id = 0x05; + priority_update2.priority_field_value = "foo"; + + uint8_t output2[] = {0x80, 0x0f, 0x07, 0x00, // type (PRIORITY_UPDATE) + 0x04, // length + 0x05, // prioritized element id + 0x66, 0x6f, 0x6f}; // priority field value: "foo" + + std::string frame2 = + HttpEncoder::SerializePriorityUpdateFrame(priority_update2); + quiche::test::CompareCharArraysWithHexError( + "PRIORITY_UPDATE", frame2.data(), frame2.length(), + reinterpret_cast<char*>(output2), ABSL_ARRAYSIZE(output2)); } TEST(HttpEncoderTest, SerializeAcceptChFrame) {
diff --git a/quiche/quic/core/http/http_frames.h b/quiche/quic/core/http/http_frames.h index f55881a..56caca8 100644 --- a/quiche/quic/core/http/http_frames.h +++ b/quiche/quic/core/http/http_frames.h
@@ -104,32 +104,24 @@ // The PRIORITY_UPDATE frame specifies the sender-advised priority of a stream. // Frame type 0xf0700 (called PRIORITY_UPDATE_REQUEST_STREAM in the // implementation) is used for for request streams. -// Frame type 0xf0701 is used for push streams and is not implemented. +// Frame type 0xf0701 would be used for push streams but it is not implemented; +// incoming 0xf0701 frames are treated as frames of unknown type. // Length of a priority frame's first byte. const QuicByteCount kPriorityFirstByteLength = 1; -enum PrioritizedElementType : uint8_t { - REQUEST_STREAM = 0x00, - PUSH_STREAM = 0x80, -}; - struct QUIC_EXPORT_PRIVATE PriorityUpdateFrame { - PrioritizedElementType prioritized_element_type = REQUEST_STREAM; uint64_t prioritized_element_id = 0; std::string priority_field_value; bool operator==(const PriorityUpdateFrame& rhs) const { - return std::tie(prioritized_element_type, prioritized_element_id, - priority_field_value) == - std::tie(rhs.prioritized_element_type, rhs.prioritized_element_id, - rhs.priority_field_value); + return std::tie(prioritized_element_id, priority_field_value) == + std::tie(rhs.prioritized_element_id, rhs.priority_field_value); } std::string ToString() const { - return absl::StrCat("Priority Frame : {prioritized_element_type: ", - static_cast<int>(prioritized_element_type), - ", prioritized_element_id: ", prioritized_element_id, - ", priority_field_value: ", priority_field_value, "}"); + return absl::StrCat( + "Priority Frame : {prioritized_element_id: ", prioritized_element_id, + ", priority_field_value: ", priority_field_value, "}"); } friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(
diff --git a/quiche/quic/core/http/http_frames_test.cc b/quiche/quic/core/http/http_frames_test.cc index 446a6b9..ba63371 100644 --- a/quiche/quic/core/http/http_frames_test.cc +++ b/quiche/quic/core/http/http_frames_test.cc
@@ -45,30 +45,23 @@ } TEST(HttpFramesTest, PriorityUpdateFrame) { - PriorityUpdateFrame a{REQUEST_STREAM, 0, ""}; + PriorityUpdateFrame a{0, ""}; EXPECT_TRUE(a == a); - PriorityUpdateFrame b{REQUEST_STREAM, 4, ""}; + PriorityUpdateFrame b{4, ""}; EXPECT_FALSE(a == b); a.prioritized_element_id = 4; EXPECT_TRUE(a == b); - a.prioritized_element_type = PUSH_STREAM; - EXPECT_FALSE(a == b); - b.prioritized_element_type = PUSH_STREAM; - EXPECT_TRUE(a == b); - a.priority_field_value = "foo"; EXPECT_FALSE(a == b); EXPECT_EQ( - "Priority Frame : {prioritized_element_type: 128, " - "prioritized_element_id: 4, priority_field_value: foo}", + "Priority Frame : {prioritized_element_id: 4, priority_field_value: foo}", a.ToString()); std::stringstream s; s << a; EXPECT_EQ( - "Priority Frame : {prioritized_element_type: 128, " - "prioritized_element_id: 4, priority_field_value: foo}", + "Priority Frame : {prioritized_element_id: 4, priority_field_value: foo}", s.str()); }
diff --git a/quiche/quic/core/http/quic_receive_control_stream.cc b/quiche/quic/core/http/quic_receive_control_stream.cc index 046507b..3c1f3e7 100644 --- a/quiche/quic/core/http/quic_receive_control_stream.cc +++ b/quiche/quic/core/http/quic_receive_control_stream.cc
@@ -159,12 +159,8 @@ return false; } - if (frame.prioritized_element_type == REQUEST_STREAM) { - return spdy_session_->OnPriorityUpdateForRequestStream( - frame.prioritized_element_id, urgency); - } else { - return true; - } + return spdy_session_->OnPriorityUpdateForRequestStream( + frame.prioritized_element_id, urgency); } // Ignore frame if no urgency parameter can be parsed.
diff --git a/quiche/quic/core/http/quic_spdy_session_test.cc b/quiche/quic/core/http/quic_spdy_session_test.cc index 7897570..aa7ba10 100644 --- a/quiche/quic/core/http/quic_spdy_session_test.cc +++ b/quiche/quic/core/http/quic_spdy_session_test.cc
@@ -2211,10 +2211,7 @@ // PRIORITY_UPDATE frame for first request stream. const QuicStreamId stream_id1 = GetNthClientInitiatedBidirectionalId(0); - struct PriorityUpdateFrame priority_update1; - priority_update1.prioritized_element_type = REQUEST_STREAM; - priority_update1.prioritized_element_id = stream_id1; - priority_update1.priority_field_value = "u=2"; + PriorityUpdateFrame priority_update1{stream_id1, "u=2"}; std::string serialized_priority_update1 = HttpEncoder::SerializePriorityUpdateFrame(priority_update1); QuicStreamFrame data3(receive_control_stream_id, @@ -2231,10 +2228,7 @@ // PRIORITY_UPDATE frame for second request stream. const QuicStreamId stream_id2 = GetNthClientInitiatedBidirectionalId(1); - struct PriorityUpdateFrame priority_update2; - priority_update2.prioritized_element_type = REQUEST_STREAM; - priority_update2.prioritized_element_id = stream_id2; - priority_update2.priority_field_value = "u=2"; + PriorityUpdateFrame priority_update2{stream_id2, "u=2"}; std::string serialized_priority_update2 = HttpEncoder::SerializePriorityUpdateFrame(priority_update2); QuicStreamFrame stream_frame3(receive_control_stream_id,
diff --git a/quiche/quic/core/http/quic_spdy_stream.cc b/quiche/quic/core/http/quic_spdy_stream.cc index ee1e685..ed0dd74 100644 --- a/quiche/quic/core/http/quic_spdy_stream.cc +++ b/quiche/quic/core/http/quic_spdy_stream.cc
@@ -594,10 +594,7 @@ } last_sent_urgency_ = urgency; - PriorityUpdateFrame priority_update; - priority_update.prioritized_element_type = REQUEST_STREAM; - priority_update.prioritized_element_id = id(); - priority_update.priority_field_value = absl::StrCat("u=", urgency); + PriorityUpdateFrame priority_update{id(), absl::StrCat("u=", urgency)}; spdy_session_->WriteHttp3PriorityUpdate(priority_update); }
diff --git a/quiche/quic/core/http/quic_spdy_stream_test.cc b/quiche/quic/core/http/quic_spdy_stream_test.cc index 81f6d0a..a147e93 100644 --- a/quiche/quic/core/http/quic_spdy_stream_test.cc +++ b/quiche/quic/core/http/quic_spdy_stream_test.cc
@@ -1560,10 +1560,10 @@ StrictMock<MockHttp3DebugVisitor> debug_visitor; session_->set_debug_visitor(&debug_visitor); - // Two writes on the request stream: HEADERS frame header and payload. if (GetQuicReloadableFlag(quic_one_write_for_headers)) { EXPECT_CALL(*session_, WritevData(stream_->id(), _, _, _, _, _)).Times(1); } else { + // Two writes on the request stream: HEADERS frame header and payload. EXPECT_CALL(*session_, WritevData(stream_->id(), _, _, _, _, _)).Times(2); } EXPECT_CALL(*stream_, WriteHeadersMock(false)); @@ -1574,9 +1574,7 @@ auto send_control_stream = QuicSpdySessionPeer::GetSendControlStream(session_.get()); EXPECT_CALL(*session_, WritevData(send_control_stream->id(), _, _, _, _, _)); - PriorityUpdateFrame priority_update; - priority_update.prioritized_element_id = 0; - priority_update.priority_field_value = "u=0"; + PriorityUpdateFrame priority_update{stream_->id(), "u=0"}; EXPECT_CALL(debug_visitor, OnPriorityUpdateFrameSent(priority_update)); stream_->SetPriority(spdy::SpdyStreamPrecedence(kV3HighestPriority)); }