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

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
« no previous file with comments | « net/websockets/websocket_extension.h ('k') | net/websockets/websocket_extension_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_extension.cc
diff --git a/net/websockets/websocket_extension.cc b/net/websockets/websocket_extension.cc
index bf7a54bdbf3e17b79f4da23476525ea19d11a39e..c5e8e1720bf237e695df3c79a7efd8252e8f5ffc 100644
--- a/net/websockets/websocket_extension.cc
+++ b/net/websockets/websocket_extension.cc
@@ -8,6 +8,7 @@
#include <string>
#include "base/logging.h"
+#include "net/http/http_util.h"
namespace net {
@@ -18,6 +19,8 @@ WebSocketExtension::Parameter::Parameter(const std::string& name,
const std::string& value)
: name_(name), value_(value) {
DCHECK(!value.empty());
+ // |extension-param| must be a token.
+ DCHECK(HttpUtil::IsToken(value));
}
bool WebSocketExtension::Parameter::Equals(const Parameter& other) const {
@@ -45,4 +48,22 @@ 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;
+
+ // |extension-param| must be a token and we don't need to quote it.
+ DCHECK(HttpUtil::IsToken(param.value()));
+ result += "=" + param.value();
+ }
+ return result;
+}
+
} // namespace net
« no previous file with comments | « net/websockets/websocket_extension.h ('k') | net/websockets/websocket_extension_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698