| 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 "net/server/web_socket.h" | 5 #include "net/server/web_socket.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 connection_->id(), | 74 connection_->id(), |
| 75 base::StringPrintf("HTTP/1.1 101 WebSocket Protocol Handshake\r\n" | 75 base::StringPrintf("HTTP/1.1 101 WebSocket Protocol Handshake\r\n" |
| 76 "Upgrade: WebSocket\r\n" | 76 "Upgrade: WebSocket\r\n" |
| 77 "Connection: Upgrade\r\n" | 77 "Connection: Upgrade\r\n" |
| 78 "Sec-WebSocket-Origin: %s\r\n" | 78 "Sec-WebSocket-Origin: %s\r\n" |
| 79 "Sec-WebSocket-Location: %s\r\n" | 79 "Sec-WebSocket-Location: %s\r\n" |
| 80 "\r\n", | 80 "\r\n", |
| 81 origin.c_str(), | 81 origin.c_str(), |
| 82 location.c_str())); | 82 location.c_str())); |
| 83 server_->SendRaw(connection_->id(), | 83 server_->SendRaw(connection_->id(), |
| 84 std::string(reinterpret_cast<char*>(digest.a), 16)); | 84 std::string(reinterpret_cast<char*>(digest), 16)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 ParseResult Read(std::string* message) override { | 87 ParseResult Read(std::string* message) override { |
| 88 DCHECK(message); | 88 DCHECK(message); |
| 89 HttpConnection::ReadIOBuffer* read_buf = connection_->read_buf(); | 89 HttpConnection::ReadIOBuffer* read_buf = connection_->read_buf(); |
| 90 if (read_buf->StartOfBuffer()[0]) | 90 if (read_buf->StartOfBuffer()[0]) |
| 91 return FRAME_ERROR; | 91 return FRAME_ERROR; |
| 92 | 92 |
| 93 base::StringPiece data(read_buf->StartOfBuffer(), read_buf->GetSize()); | 93 base::StringPiece data(read_buf->StartOfBuffer(), read_buf->GetSize()); |
| 94 size_t pos = data.find('\377', 1); | 94 size_t pos = data.find('\377', 1); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 WebSocket::WebSocket(HttpServer* server, HttpConnection* connection) | 251 WebSocket::WebSocket(HttpServer* server, HttpConnection* connection) |
| 252 : server_(server), | 252 : server_(server), |
| 253 connection_(connection) { | 253 connection_(connection) { |
| 254 } | 254 } |
| 255 | 255 |
| 256 WebSocket::~WebSocket() { | 256 WebSocket::~WebSocket() { |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace net | 259 } // namespace net |
| OLD | NEW |