summaryrefslogtreecommitdiffstats
path: root/net/websockets/websocket_basic_stream.cc
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 11:27:55 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 11:27:55 +0000
commite678d4fec79f0a1b5e0c44edf04fe441d00b3901 (patch)
tree4eabd5d753dad96e5b1a4522473cd00eaf92ed5b /net/websockets/websocket_basic_stream.cc
parent46d46055fa8fb752bcab72ed1476e81924f5a74d (diff)
downloadchromium_src-e678d4fec79f0a1b5e0c44edf04fe441d00b3901.zip
chromium_src-e678d4fec79f0a1b5e0c44edf04fe441d00b3901.tar.gz
chromium_src-e678d4fec79f0a1b5e0c44edf04fe441d00b3901.tar.bz2
Retain empty first frames as well as final frames.
If the payload of the first frame of a multi-frame message was empty, then the type of the message would be lost. To avoid this, always retain the first chunk of the first frame of a message, even if the payload is empty. Also add tests for empty frames, a frame larger than the read buffer, and a masked frame with a non-nul mask. Changed some ASSERT_EQ() statements that weren't necessary to prevent tests from crashing or hanging into EXPECT_EQ() statements. BUG=305081 Review URL: https://codereview.chromium.org/26440002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets/websocket_basic_stream.cc')
-rw-r--r--net/websockets/websocket_basic_stream.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/websockets/websocket_basic_stream.cc b/net/websockets/websocket_basic_stream.cc
index f5d9a76..d3b1c40 100644
--- a/net/websockets/websocket_basic_stream.cc
+++ b/net/websockets/websocket_basic_stream.cc
@@ -379,9 +379,11 @@ scoped_ptr<WebSocketFrame> WebSocketBasicStream::CreateFrame(
is_final_chunk && current_frame_header_->final;
const int data_size = data ? data->size() : 0;
const WebSocketFrameHeader::OpCode opcode = current_frame_header_->opcode;
- // Empty frames convey no useful information unless they have the "final" bit
- // set.
- if (is_final_chunk_in_message || data_size > 0) {
+ // Empty frames convey no useful information unless they are the first frame
+ // (containing the type and flags) or have the "final" bit set.
+ if (is_final_chunk_in_message || data_size > 0 ||
+ current_frame_header_->opcode !=
+ WebSocketFrameHeader::kOpCodeContinuation) {
result_frame.reset(new WebSocketFrame(opcode));
result_frame->header.CopyFrom(*current_frame_header_);
result_frame->header.final = is_final_chunk_in_message;