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" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 std::multimap<std::string, std::string> this_parameters, other_parameters; | 38 std::multimap<std::string, std::string> this_parameters, other_parameters; |
| 39 for (const auto& p : parameters_) { | 39 for (const auto& p : parameters_) { |
| 40 this_parameters.insert(std::make_pair(p.name(), p.value())); | 40 this_parameters.insert(std::make_pair(p.name(), p.value())); |
| 41 } | 41 } |
| 42 for (const auto& p : other.parameters_) { | 42 for (const auto& p : other.parameters_) { |
| 43 other_parameters.insert(std::make_pair(p.name(), p.value())); | 43 other_parameters.insert(std::make_pair(p.name(), p.value())); |
| 44 } | 44 } |
| 45 return this_parameters == other_parameters; | 45 return this_parameters == other_parameters; |
| 46 } | 46 } |
| 47 | 47 |
| 48 std::string WebSocketExtension::ToString() const { | |
| 49 if (name_.empty()) { | |
| 50 return std::string(); | |
| 51 } | |
| 52 | |
| 53 std::string result = name_; | |
| 54 | |
| 55 for (const auto& param : parameters_) { | |
| 56 result += "; " + param.name(); | |
| 57 if (param.HasValue()) { | |
|
tyoshino (SeeGerritForStatus)
2015/09/11 12:18:40
if (!param.HasValue())
continue;
yhirano
2015/09/15 06:25:57
Done.
| |
| 58 result += "="; | |
| 59 const auto& value = param.value(); | |
| 60 if (value.find('"') == std::string::npos) { | |
| 61 result += value; | |
| 62 } else { | |
| 63 result += '"'; | |
| 64 for (const auto& c : value) { | |
| 65 if (c == '"') { | |
| 66 result += "\\\""; | |
| 67 } else { | |
| 68 result += c; | |
| 69 } | |
| 70 } | |
| 71 result += '"'; | |
| 72 } | |
| 73 } | |
| 74 } | |
| 75 return result; | |
| 76 } | |
| 77 | |
| 48 } // namespace net | 78 } // namespace net |
| OLD | NEW |