| Index: net/server/web_socket.cc
|
| diff --git a/net/server/web_socket.cc b/net/server/web_socket.cc
|
| index f06b425fee018c4f8d1020c4a94a02f00e1bbd56..5810aa831b129b2995d5b52aca14f750d1023c66 100644
|
| --- a/net/server/web_socket.cc
|
| +++ b/net/server/web_socket.cc
|
| @@ -46,7 +46,8 @@ class WebSocketHixie76 : public net::WebSocket {
|
| static net::WebSocket* Create(HttpConnection* connection,
|
| const HttpServerRequestInfo& request,
|
| size_t* pos) {
|
| - if (connection->recv_data().length() < *pos + kWebSocketHandshakeBodyLen)
|
| + if (connection->read_buf()->GetUnconsumedSize()
|
| + < *pos + kWebSocketHandshakeBodyLen)
|
| return NULL;
|
| return new WebSocketHixie76(connection, request, pos);
|
| }
|
| @@ -83,17 +84,17 @@ class WebSocketHixie76 : public net::WebSocket {
|
|
|
| virtual ParseResult Read(std::string* message) OVERRIDE {
|
| DCHECK(message);
|
| - const std::string& data = connection_->recv_data();
|
| - if (data[0])
|
| + HttpConnection::ReadIOBuffer* read_buf = connection_->read_buf();
|
| + if (read_buf->data()[0])
|
| return FRAME_ERROR;
|
|
|
| + std::string data(read_buf->data(), read_buf->GetUnconsumedSize());
|
| size_t pos = data.find('\377', 1);
|
| if (pos == std::string::npos)
|
| return FRAME_INCOMPLETE;
|
|
|
| - std::string buffer(data.begin() + 1, data.begin() + pos);
|
| - message->swap(buffer);
|
| - connection_->Shift(pos + 1);
|
| + message->assign(read_buf->data() + 1, pos - 1);
|
| + read_buf->DidConsume(pos + 1);
|
|
|
| return FRAME_OK;
|
| }
|
| @@ -129,9 +130,8 @@ class WebSocketHixie76 : public net::WebSocket {
|
| return;
|
| }
|
|
|
| - key3_ = connection->recv_data().substr(
|
| - *pos,
|
| - *pos + kWebSocketHandshakeBodyLen);
|
| + key3_.assign(connection->read_buf()->data() + *pos,
|
| + kWebSocketHandshakeBodyLen);
|
| *pos += kWebSocketHandshakeBodyLen;
|
| }
|
|
|
| @@ -205,13 +205,14 @@ class WebSocketHybi17 : public WebSocket {
|
| }
|
|
|
| virtual ParseResult Read(std::string* message) OVERRIDE {
|
| - const std::string& frame = connection_->recv_data();
|
| + HttpConnection::ReadIOBuffer* read_buf = connection_->read_buf();
|
| + const std::string frame(read_buf->data(), read_buf->GetUnconsumedSize());
|
| int bytes_consumed = 0;
|
|
|
| ParseResult result =
|
| WebSocket::DecodeFrameHybi17(frame, true, &bytes_consumed, message);
|
| if (result == FRAME_OK)
|
| - connection_->Shift(bytes_consumed);
|
| + read_buf->DidConsume(bytes_consumed);
|
| if (result == FRAME_CLOSE)
|
| closed_ = true;
|
| return result;
|
|
|