Chromium Code Reviews| 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_extension.h" | 5 #include "net/websockets/websocket_extension.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "net/http/http_util.h" | |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 WebSocketExtension::Parameter::Parameter(const std::string& name) | 15 WebSocketExtension::Parameter::Parameter(const std::string& name) |
| 15 : name_(name) {} | 16 : name_(name) {} |
| 16 | 17 |
| 17 WebSocketExtension::Parameter::Parameter(const std::string& name, | 18 WebSocketExtension::Parameter::Parameter(const std::string& name, |
| 18 const std::string& value) | 19 const std::string& value) |
| 19 : name_(name), value_(value) { | 20 : name_(name), value_(value) { |
| 20 DCHECK(!value.empty()); | 21 DCHECK(!value.empty()); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 38 std::multimap<std::string, std::string> this_parameters, other_parameters; | 39 std::multimap<std::string, std::string> this_parameters, other_parameters; |
| 39 for (const auto& p : parameters_) { | 40 for (const auto& p : parameters_) { |
| 40 this_parameters.insert(std::make_pair(p.name(), p.value())); | 41 this_parameters.insert(std::make_pair(p.name(), p.value())); |
| 41 } | 42 } |
| 42 for (const auto& p : other.parameters_) { | 43 for (const auto& p : other.parameters_) { |
| 43 other_parameters.insert(std::make_pair(p.name(), p.value())); | 44 other_parameters.insert(std::make_pair(p.name(), p.value())); |
| 44 } | 45 } |
| 45 return this_parameters == other_parameters; | 46 return this_parameters == other_parameters; |
| 46 } | 47 } |
| 47 | 48 |
| 49 std::string WebSocketExtension::ToString() const { | |
| 50 if (name_.empty()) { | |
| 51 return std::string(); | |
| 52 } | |
| 53 | |
| 54 std::string result = name_; | |
| 55 | |
| 56 for (const auto& param : parameters_) { | |
| 57 result += "; " + param.name(); | |
| 58 if (!param.HasValue()) | |
| 59 continue; | |
| 60 | |
| 61 // |extension-param| must be a token and we don't need to quote it. | |
| 62 DCHECK(HttpUtil::IsToken(param.value())); | |
|
tyoshino (SeeGerritForStatus)
2015/09/17 02:24:37
the parser is ok. it's checking if the unquoted da
yhirano
2015/09/17 03:32:15
Done.
| |
| 63 result += "=" + param.value(); | |
| 64 } | |
| 65 return result; | |
| 66 } | |
| 67 | |
| 48 } // namespace net | 68 } // namespace net |
| OLD | NEW |