| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_basic_handshake_stream.h" | 5 #include "net/websockets/websocket_basic_handshake_stream.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 std::string MultipleHeaderValuesMessage(const std::string& header_name) { | 78 std::string MultipleHeaderValuesMessage(const std::string& header_name) { |
| 79 return | 79 return |
| 80 std::string("'") + | 80 std::string("'") + |
| 81 header_name + | 81 header_name + |
| 82 "' header must not appear more than once in a response"; | 82 "' header must not appear more than once in a response"; |
| 83 } | 83 } |
| 84 | 84 |
| 85 std::string GenerateHandshakeChallenge() { | 85 std::string GenerateHandshakeChallenge() { |
| 86 std::string raw_challenge(websockets::kRawChallengeLength, '\0'); | 86 std::string raw_challenge(websockets::kRawChallengeLength, '\0'); |
| 87 crypto::RandBytes(string_as_array(&raw_challenge), raw_challenge.length()); | 87 crypto::RandBytes(base::string_as_array(&raw_challenge), |
| 88 raw_challenge.length()); |
| 88 std::string encoded_challenge; | 89 std::string encoded_challenge; |
| 89 base::Base64Encode(raw_challenge, &encoded_challenge); | 90 base::Base64Encode(raw_challenge, &encoded_challenge); |
| 90 return encoded_challenge; | 91 return encoded_challenge; |
| 91 } | 92 } |
| 92 | 93 |
| 93 void AddVectorHeaderIfNonEmpty(const char* name, | 94 void AddVectorHeaderIfNonEmpty(const char* name, |
| 94 const std::vector<std::string>& value, | 95 const std::vector<std::string>& value, |
| 95 HttpRequestHeaders* headers) { | 96 HttpRequestHeaders* headers) { |
| 96 if (value.empty()) | 97 if (value.empty()) |
| 97 return; | 98 return; |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 593 } |
| 593 OnFailure("Error during WebSocket handshake: " + failure_message); | 594 OnFailure("Error during WebSocket handshake: " + failure_message); |
| 594 return ERR_INVALID_RESPONSE; | 595 return ERR_INVALID_RESPONSE; |
| 595 } | 596 } |
| 596 | 597 |
| 597 void WebSocketBasicHandshakeStream::OnFailure(const std::string& message) { | 598 void WebSocketBasicHandshakeStream::OnFailure(const std::string& message) { |
| 598 stream_request_->OnFailure(message); | 599 stream_request_->OnFailure(message); |
| 599 } | 600 } |
| 600 | 601 |
| 601 } // namespace net | 602 } // namespace net |
| OLD | NEW |