| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/chromedriver/net/websocket.h" | 5 #include "chrome/test/chromedriver/net/websocket.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 std::string handshake = base::StringPrintf( | 137 std::string handshake = base::StringPrintf( |
| 138 "GET %s HTTP/1.1\r\n" | 138 "GET %s HTTP/1.1\r\n" |
| 139 "Host: %s\r\n" | 139 "Host: %s\r\n" |
| 140 "Upgrade: websocket\r\n" | 140 "Upgrade: websocket\r\n" |
| 141 "Connection: Upgrade\r\n" | 141 "Connection: Upgrade\r\n" |
| 142 "Sec-WebSocket-Key: %s\r\n" | 142 "Sec-WebSocket-Key: %s\r\n" |
| 143 "Sec-WebSocket-Version: 13\r\n" | 143 "Sec-WebSocket-Version: 13\r\n" |
| 144 "Pragma: no-cache\r\n" | 144 "Pragma: no-cache\r\n" |
| 145 "Cache-Control: no-cache\r\n" | 145 "Cache-Control: no-cache\r\n" |
| 146 "\r\n", | 146 "\r\n", |
| 147 url_.path().c_str(), | 147 url_.path().as_string().c_str(), url_.host().c_str(), sec_key_.c_str()); |
| 148 url_.host().c_str(), | |
| 149 sec_key_.c_str()); | |
| 150 Write(handshake); | 148 Write(handshake); |
| 151 Read(); | 149 Read(); |
| 152 } | 150 } |
| 153 | 151 |
| 154 void WebSocket::Write(const std::string& data) { | 152 void WebSocket::Write(const std::string& data) { |
| 155 pending_write_ += data; | 153 pending_write_ += data; |
| 156 if (!write_buffer_->BytesRemaining()) | 154 if (!write_buffer_->BytesRemaining()) |
| 157 ContinueWritingIfNecessary(); | 155 ContinueWritingIfNecessary(); |
| 158 } | 156 } |
| 159 | 157 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 265 |
| 268 void WebSocket::Close(int code) { | 266 void WebSocket::Close(int code) { |
| 269 socket_->Disconnect(); | 267 socket_->Disconnect(); |
| 270 if (!connect_callback_.is_null()) | 268 if (!connect_callback_.is_null()) |
| 271 InvokeConnectCallback(code); | 269 InvokeConnectCallback(code); |
| 272 if (state_ == OPEN) | 270 if (state_ == OPEN) |
| 273 listener_->OnClose(); | 271 listener_->OnClose(); |
| 274 | 272 |
| 275 state_ = CLOSED; | 273 state_ = CLOSED; |
| 276 } | 274 } |
| OLD | NEW |