| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool ValidatePerMessageDeflateExtension(const WebSocketExtension& extension, | 267 bool ValidatePerMessageDeflateExtension(const WebSocketExtension& extension, |
| 268 std::string* failure_message, | 268 std::string* failure_message, |
| 269 WebSocketExtensionParams* params) { | 269 WebSocketExtensionParams* params) { |
| 270 static const char kClientPrefix[] = "client_"; | 270 static const char kClientPrefix[] = "client_"; |
| 271 static const char kServerPrefix[] = "server_"; | 271 static const char kServerPrefix[] = "server_"; |
| 272 static const char kNoContextTakeover[] = "no_context_takeover"; | 272 static const char kNoContextTakeover[] = "no_context_takeover"; |
| 273 static const char kMaxWindowBits[] = "max_window_bits"; | 273 static const char kMaxWindowBits[] = "max_window_bits"; |
| 274 const size_t kPrefixLen = arraysize(kClientPrefix) - 1; | 274 const size_t kPrefixLen = arraysize(kClientPrefix) - 1; |
| 275 COMPILE_ASSERT(kPrefixLen == arraysize(kServerPrefix) - 1, | 275 static_assert(kPrefixLen == arraysize(kServerPrefix) - 1, |
| 276 the_strings_server_and_client_must_be_the_same_length); | 276 "the strings server and client must be the same length"); |
| 277 typedef std::vector<WebSocketExtension::Parameter> ParameterVector; | 277 typedef std::vector<WebSocketExtension::Parameter> ParameterVector; |
| 278 | 278 |
| 279 DCHECK_EQ("permessage-deflate", extension.name()); | 279 DCHECK_EQ("permessage-deflate", extension.name()); |
| 280 const ParameterVector& parameters = extension.parameters(); | 280 const ParameterVector& parameters = extension.parameters(); |
| 281 std::set<std::string> seen_names; | 281 std::set<std::string> seen_names; |
| 282 for (ParameterVector::const_iterator it = parameters.begin(); | 282 for (ParameterVector::const_iterator it = parameters.begin(); |
| 283 it != parameters.end(); ++it) { | 283 it != parameters.end(); ++it) { |
| 284 const std::string& name = it->name(); | 284 const std::string& name = it->name(); |
| 285 if (seen_names.count(name) != 0) { | 285 if (seen_names.count(name) != 0) { |
| 286 return DeflateError( | 286 return DeflateError( |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 set_failure_message("Error during WebSocket handshake: " + failure_message); | 680 set_failure_message("Error during WebSocket handshake: " + failure_message); |
| 681 return ERR_INVALID_RESPONSE; | 681 return ERR_INVALID_RESPONSE; |
| 682 } | 682 } |
| 683 | 683 |
| 684 void WebSocketBasicHandshakeStream::set_failure_message( | 684 void WebSocketBasicHandshakeStream::set_failure_message( |
| 685 const std::string& failure_message) { | 685 const std::string& failure_message) { |
| 686 *failure_message_ = failure_message; | 686 *failure_message_ = failure_message; |
| 687 } | 687 } |
| 688 | 688 |
| 689 } // namespace net | 689 } // namespace net |
| OLD | NEW |