| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/websockets/websocket_handshake.h" | 5 #include "net/websockets/websocket_handshake.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 fields.push_back("Origin: " + GetOriginFieldValue()); | 63 fields.push_back("Origin: " + GetOriginFieldValue()); |
| 64 | 64 |
| 65 if (!protocol_.empty()) | 65 if (!protocol_.empty()) |
| 66 fields.push_back("Sec-WebSocket-Protocol: " + protocol_); | 66 fields.push_back("Sec-WebSocket-Protocol: " + protocol_); |
| 67 | 67 |
| 68 // TODO(ukai): Add cookie if necessary. | 68 // TODO(ukai): Add cookie if necessary. |
| 69 | 69 |
| 70 fields.push_back("Sec-WebSocket-Key1: " + parameter_->GetSecWebSocketKey1()); | 70 fields.push_back("Sec-WebSocket-Key1: " + parameter_->GetSecWebSocketKey1()); |
| 71 fields.push_back("Sec-WebSocket-Key2: " + parameter_->GetSecWebSocketKey2()); | 71 fields.push_back("Sec-WebSocket-Key2: " + parameter_->GetSecWebSocketKey2()); |
| 72 | 72 |
| 73 std::random_shuffle(fields.begin(), fields.end()); | 73 std::random_shuffle(fields.begin(), fields.end(), base::RandGenerator); |
| 74 | 74 |
| 75 for (size_t i = 0; i < fields.size(); i++) { | 75 for (size_t i = 0; i < fields.size(); i++) { |
| 76 msg += fields[i] + "\r\n"; | 76 msg += fields[i] + "\r\n"; |
| 77 } | 77 } |
| 78 msg += "\r\n"; | 78 msg += "\r\n"; |
| 79 | 79 |
| 80 msg.append(parameter_->GetKey3()); | 80 msg.append(parameter_->GetKey3()); |
| 81 return msg; | 81 return msg; |
| 82 } | 82 } |
| 83 | 83 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 | 297 |
| 298 void WebSocketHandshake::Parameter::GenerateKey3() { | 298 void WebSocketHandshake::Parameter::GenerateKey3() { |
| 299 key_3_.clear(); | 299 key_3_.clear(); |
| 300 for (int i = 0; i < 8; i++) { | 300 for (int i = 0; i < 8; i++) { |
| 301 key_3_.append(1, rand_(0, 255)); | 301 key_3_.append(1, rand_(0, 255)); |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace net | 305 } // namespace net |
| OLD | NEW |