Make writing Prioritized Element ID and Element Dependency ID optional when handling priority.
These fields are specified to be absent when priority type or dependency type is ROOT_OF_TREE.
On the decoding side, the absent fields will be parsed as 0 for default value. Those fields won't be used when later the frame is processed.
gfe-relnote: v99 only, not flag protected.
PiperOrigin-RevId: 254072432
Change-Id: I336e06b39d89ff01507e54818dafa67923e96e4c
diff --git a/quic/core/http/http_decoder.cc b/quic/core/http/http_decoder.cc
index f08d2ff..4513f04 100644
--- a/quic/core/http/http_decoder.cc
+++ b/quic/core/http/http_decoder.cc
@@ -519,11 +519,13 @@
frame->dependency_type =
static_cast<PriorityElementType>(ExtractBits(flags, 2, 4));
frame->exclusive = flags % 2 == 1;
- if (!reader->ReadVarInt62(&frame->prioritized_element_id)) {
+ if (frame->prioritized_type != ROOT_OF_TREE &&
+ !reader->ReadVarInt62(&frame->prioritized_element_id)) {
RaiseError(QUIC_INTERNAL_ERROR, "Unable to read prioritized_element_id");
return false;
}
- if (!reader->ReadVarInt62(&frame->element_dependency_id)) {
+ if (frame->dependency_type != ROOT_OF_TREE &&
+ !reader->ReadVarInt62(&frame->element_dependency_id)) {
RaiseError(QUIC_INTERNAL_ERROR, "Unable to read element_dependency_id");
return false;
}