Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: net/websockets/websocket_extension.cc

Issue 1340523002: Fix WebSocketServer extension parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ws-constructor-fix
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/websockets/websocket_extension.cc
diff --git a/net/websockets/websocket_extension.cc b/net/websockets/websocket_extension.cc
index bf7a54bdbf3e17b79f4da23476525ea19d11a39e..f1e6a24090ccf8831125ba916f043ec7780365f5 100644
--- a/net/websockets/websocket_extension.cc
+++ b/net/websockets/websocket_extension.cc
@@ -45,4 +45,35 @@ bool WebSocketExtension::Equals(const WebSocketExtension& other) const {
return this_parameters == other_parameters;
}
+std::string WebSocketExtension::ToString() const {
+ if (name_.empty()) {
+ return std::string();
+ }
+
+ std::string result = name_;
+
+ for (const auto& param : parameters_) {
+ result += "; " + param.name();
+ if (!param.HasValue())
+ continue;
+
+ result += "=";
+ const auto& value = param.value();
+ if (value.find('"') == std::string::npos) {
+ result += value;
+ } else {
+ result += '"';
tyoshino (SeeGerritForStatus) 2015/09/16 09:33:10 per HTTP rfc, we need to scan all non-token charac
yhirano 2015/09/16 10:47:46 Done.
+ for (const auto& c : value) {
+ if (c == '"') {
+ result += "\\\"";
+ } else {
+ result += c;
+ }
+ }
+ result += '"';
+ }
+ }
+ return result;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698