diff options
author | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 16:14:49 +0000 |
---|---|---|
committer | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 16:14:49 +0000 |
commit | c51ab1223baa573bd74182b6679e89e4e205fa11 (patch) | |
tree | e8de30be404926893a5e36d035f5ee792fa50a1a /net/server/web_socket.cc | |
parent | a89e09411e25b190474b01305fb6e562cd2361ba (diff) | |
download | chromium_src-c51ab1223baa573bd74182b6679e89e4e205fa11.zip chromium_src-c51ab1223baa573bd74182b6679e89e4e205fa11.tar.gz chromium_src-c51ab1223baa573bd74182b6679e89e4e205fa11.tar.bz2 |
DevTools: web socket does not expect frames other than text.
BUG=97974
TEST=none
Review URL: http://codereview.chromium.org/8043023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/server/web_socket.cc')
-rw-r--r-- | net/server/web_socket.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/net/server/web_socket.cc b/net/server/web_socket.cc index de5e33a..2409e0c 100644 --- a/net/server/web_socket.cc +++ b/net/server/web_socket.cc @@ -223,7 +223,19 @@ class WebSocketHybi10 : public WebSocket { op_code_ = first_byte & kOpCodeMask; masked_ = second_byte & kMaskBit; - CHECK_EQ(kOpCodeText, op_code_); + switch (op_code_) { + case kOpCodeClose: + closed_ = true; + break; + case kOpCodeText: + break; + case kOpCodeBinary: // We don't support binary frames yet. + case kOpCodeContinuation: // We don't support binary frames yet. + case kOpCodePing: // We don't support binary frames yet. + case kOpCodePong: // We don't support binary frames yet. + default: + return FRAME_ERROR; + } uint64 payload_length64 = second_byte & kPayloadLengthMask; if (payload_length64 > kMaxSingleBytePayloadLength) { @@ -271,10 +283,14 @@ class WebSocketHybi10 : public WebSocket { size_t pos = p + masking_key_length + payload_length_ - connection_->recv_data().c_str(); connection_->Shift(pos); - return FRAME_OK; + + return closed_ ? FRAME_CLOSE : FRAME_OK; } virtual void Send(const std::string& message) { + if (closed_) + return; + std::vector<char> frame; OpCode op_code = kOpCodeText; size_t data_length = message.length(); @@ -331,7 +347,8 @@ class WebSocketHybi10 : public WebSocket { masked_(false), payload_(0), payload_length_(0), - frame_end_(0) { + frame_end_(0), + closed_(false) { } OpCode op_code_; @@ -343,6 +360,7 @@ class WebSocketHybi10 : public WebSocket { const char* payload_; size_t payload_length_; const char* frame_end_; + bool closed_; DISALLOW_COPY_AND_ASSIGN(WebSocketHybi10); }; |