Index: net/spdy/spdy_framer.cc |
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc |
index dc7231a0f55bbbc57aae11a0ff7fa09051ff3f3b..34e27a78d735cf46f6ba63a21bf6e149bbe8dbfc 100644 |
--- a/net/spdy/spdy_framer.cc |
+++ b/net/spdy/spdy_framer.cc |
@@ -2348,6 +2348,7 @@ SpdySerializedFrame* SpdyFramer::SerializeDataFrameHeaderWithPaddingLengthField( |
SpdySerializedFrame* SpdyFramer::SerializeSynStream( |
const SpdySynStreamIR& syn_stream) { |
+ DCHECK_GE(SPDY3, protocol_version()); |
uint8 flags = 0; |
if (syn_stream.fin()) { |
flags |= CONTROL_FLAG_FIN; |
@@ -2356,12 +2357,6 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream( |
// TODO(hkhalil): invalid for HTTP2. |
flags |= CONTROL_FLAG_UNIDIRECTIONAL; |
} |
- // In SPDY >= 4, SYN_STREAM frames are HEADERS frames, but for now |
- // we never expect to have to overflow into a CONTINUATION frame. |
- if (protocol_version() > SPDY3) { |
- flags |= HEADERS_FLAG_PRIORITY; |
- flags |= HEADERS_FLAG_END_HEADERS; |
- } |
// Sanitize priority. |
uint8 priority = syn_stream.priority(); |
@@ -2371,44 +2366,17 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream( |
} |
// The size of this frame, including variable-length name-value block. |
- size_t size = GetSynStreamMinimumSize(); |
- |
- string hpack_encoding; |
- if (protocol_version() > SPDY3) { |
- if (enable_compression_) { |
- GetHpackEncoder()->EncodeHeaderSet( |
- syn_stream.name_value_block(), &hpack_encoding); |
- } else { |
- GetHpackEncoder()->EncodeHeaderSetWithoutCompression( |
- syn_stream.name_value_block(), &hpack_encoding); |
- } |
- size += hpack_encoding.size(); |
- } else { |
- size += GetSerializedLength(syn_stream.name_value_block()); |
- } |
+ size_t size = GetSynStreamMinimumSize() + |
+ GetSerializedLength(syn_stream.name_value_block()); |
SpdyFrameBuilder builder(size, protocol_version()); |
- if (protocol_version() <= SPDY3) { |
- builder.WriteControlFrameHeader(*this, SYN_STREAM, flags); |
- builder.WriteUInt32(syn_stream.stream_id()); |
- builder.WriteUInt32(syn_stream.associated_to_stream_id()); |
- builder.WriteUInt8(priority << ((protocol_version() <= SPDY2) ? 6 : 5)); |
- builder.WriteUInt8(0); // Unused byte where credential slot used to be. |
- } else { |
- builder.BeginNewFrame(*this, |
- HEADERS, |
- flags, |
- syn_stream.stream_id()); |
- // TODO(jgraettinger): Plumb priorities and stream dependencies. |
- builder.WriteUInt32(0); // Non-exclusive bit and root stream ID. |
- builder.WriteUInt8(MapPriorityToWeight(priority)); |
- } |
+ builder.WriteControlFrameHeader(*this, SYN_STREAM, flags); |
+ builder.WriteUInt32(syn_stream.stream_id()); |
+ builder.WriteUInt32(syn_stream.associated_to_stream_id()); |
+ builder.WriteUInt8(priority << ((protocol_version() <= SPDY2) ? 6 : 5)); |
+ builder.WriteUInt8(0); // Unused byte where credential slot used to be. |
DCHECK_EQ(GetSynStreamMinimumSize(), builder.length()); |
- if (protocol_version() > SPDY3) { |
- builder.WriteBytes(&hpack_encoding[0], hpack_encoding.size()); |
- } else { |
- SerializeNameValueBlock(&builder, syn_stream); |
- } |
+ SerializeNameValueBlock(&builder, syn_stream); |
if (debug_visitor_) { |
const size_t payload_len = |
@@ -2635,7 +2603,7 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders( |
DLOG(DFATAL) << "Priority out-of-bounds."; |
priority = GetLowestPriority(); |
} |
- size += 4; |
+ size += 5; |
} |
string hpack_encoding; |
@@ -2666,11 +2634,6 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders( |
HEADERS, |
flags, |
headers.stream_id()); |
- if (headers.has_priority()) { |
- // TODO(jgraettinger): Plumb priorities and stream dependencies. |
- builder.WriteUInt32(0); // Non-exclusive bit and root stream ID. |
- builder.WriteUInt8(MapPriorityToWeight(priority)); |
- } |
} |
if (protocol_version() <= SPDY2) { |
builder.WriteUInt16(0); // Unused. |
@@ -2678,6 +2641,11 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders( |
DCHECK_EQ(GetHeadersMinimumSize(), builder.length()); |
if (protocol_version() > SPDY3) { |
+ if (headers.has_priority()) { |
+ // TODO(jgraettinger): Plumb priorities and stream dependencies. |
+ builder.WriteUInt32(0); // Non-exclusive bit and root stream ID. |
+ builder.WriteUInt8(MapPriorityToWeight(priority)); |
+ } |
WritePayloadWithContinuation(&builder, |
hpack_encoding, |
headers.stream_id(), |