summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_framer.cc
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 19:24:29 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 19:24:29 +0000
commit0558bdff21154df78ccbbd2f2ee89df4335bc911 (patch)
tree0e7332c1ce6b2ff41622f84bb74d922a83ee2b8e /net/spdy/spdy_framer.cc
parent6b2721c1fd4a3f0c4af461f2749781f77c9870ac (diff)
downloadchromium_src-0558bdff21154df78ccbbd2f2ee89df4335bc911.zip
chromium_src-0558bdff21154df78ccbbd2f2ee89df4335bc911.tar.gz
chromium_src-0558bdff21154df78ccbbd2f2ee89df4335bc911.tar.bz2
API changes and protocol changes for supporting the latest SPDY spec.
Changes include: rename FIN_STREAM to RST_STREAM update enums Add associated-to field to SYN_STREAM Update SYN_STREAM APIs Fix up unit tests. I think these are all the on-wire compatibility changes in the spec. More semantic changes are necessary, of course. BUG=none TEST=none Review URL: http://codereview.chromium.org/599018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_framer.cc')
-rw-r--r--net/spdy/spdy_framer.cc51
1 files changed, 38 insertions, 13 deletions
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 0996970..e001d86 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -284,9 +284,9 @@ void SpdyFramer::ProcessControlFrameHeader() {
SpdySynReplyControlFrame::size() - SpdyControlFrame::size())
set_error(SPDY_INVALID_CONTROL_FRAME);
break;
- case FIN_STREAM:
+ case RST_STREAM:
if (current_control_frame.length() !=
- SpdyFinStreamControlFrame::size() - SpdyFrame::size())
+ SpdyRstStreamControlFrame::size() - SpdyFrame::size())
set_error(SPDY_INVALID_CONTROL_FRAME);
break;
case NOOP:
@@ -428,9 +428,26 @@ bool SpdyFramer::ParseHeaderBlock(const SpdyFrame* frame,
scoped_ptr<SpdyFrame> decompressed_frame(DecompressFrame(frame));
if (!decompressed_frame.get())
return false;
- SpdySynStreamControlFrame syn_frame(decompressed_frame->data(), false);
- const char *header_data = syn_frame.header_block();
- int header_length = syn_frame.header_block_len();
+
+ const char *header_data = NULL;
+ int header_length = 0;
+
+ switch (type) {
+ case SYN_STREAM:
+ {
+ SpdySynStreamControlFrame syn_frame(decompressed_frame->data(), false);
+ header_data = syn_frame.header_block();
+ header_length = syn_frame.header_block_len();
+ }
+ break;
+ case SYN_REPLY:
+ {
+ SpdySynReplyControlFrame syn_frame(decompressed_frame->data(), false);
+ header_data = syn_frame.header_block();
+ header_length = syn_frame.header_block_len();
+ }
+ break;
+ }
SpdyFrameBuilder builder(header_data, header_length);
void* iter = NULL;
@@ -455,14 +472,15 @@ bool SpdyFramer::ParseHeaderBlock(const SpdyFrame* frame,
}
SpdySynStreamControlFrame* SpdyFramer::CreateSynStream(
- SpdyStreamId stream_id, int priority, SpdyControlFlags flags,
- bool compressed, SpdyHeaderBlock* headers) {
+ SpdyStreamId stream_id, SpdyStreamId associated_stream_id, int priority,
+ SpdyControlFlags flags, bool compressed, SpdyHeaderBlock* headers) {
SpdyFrameBuilder frame;
frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion);
frame.WriteUInt16(SYN_STREAM);
frame.WriteUInt32(0); // Placeholder for the length and flags
frame.WriteUInt32(stream_id);
+ frame.WriteUInt32(associated_stream_id);
frame.WriteUInt16(ntohs(priority) << 6); // Priority.
frame.WriteUInt16(headers->size()); // Number of headers.
@@ -489,15 +507,15 @@ SpdySynStreamControlFrame* SpdyFramer::CreateSynStream(
}
/* static */
-SpdyFinStreamControlFrame* SpdyFramer::CreateFinStream(SpdyStreamId stream_id,
+SpdyRstStreamControlFrame* SpdyFramer::CreateRstStream(SpdyStreamId stream_id,
int status) {
SpdyFrameBuilder frame;
frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion);
- frame.WriteUInt16(FIN_STREAM);
+ frame.WriteUInt16(RST_STREAM);
frame.WriteUInt32(8);
frame.WriteUInt32(stream_id);
frame.WriteUInt32(status);
- return reinterpret_cast<SpdyFinStreamControlFrame*>(frame.take());
+ return reinterpret_cast<SpdyRstStreamControlFrame*>(frame.take());
}
SpdySynReplyControlFrame* SpdyFramer::CreateSynReply(SpdyStreamId stream_id,
@@ -634,7 +652,6 @@ bool SpdyFramer::GetFrameBoundaries(const SpdyFrame* frame,
reinterpret_cast<const SpdyControlFrame*>(frame);
switch (control_frame->type()) {
case SYN_STREAM:
- case SYN_REPLY:
{
const SpdySynStreamControlFrame *syn_frame =
reinterpret_cast<const SpdySynStreamControlFrame*>(frame);
@@ -644,6 +661,16 @@ bool SpdyFramer::GetFrameBoundaries(const SpdyFrame* frame,
*payload = frame->data() + *header_length;
}
break;
+ case SYN_REPLY:
+ {
+ const SpdySynReplyControlFrame *syn_frame =
+ reinterpret_cast<const SpdySynReplyControlFrame*>(frame);
+ frame_size = SpdySynReplyControlFrame::size();
+ *payload_length = syn_frame->header_block_len();
+ *header_length = frame_size;
+ *payload = frame->data() + *header_length;
+ }
+ break;
default:
// TODO(mbelshe): set an error?
return false; // We can't compress this frame!
@@ -654,8 +681,6 @@ bool SpdyFramer::GetFrameBoundaries(const SpdyFrame* frame,
*payload_length = frame->length();
*payload = frame->data() + SpdyFrame::size();
}
- DCHECK(static_cast<size_t>(*header_length) <=
- SpdyFrame::size() + *payload_length);
return true;
}