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

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..30cb2ecdee3296347aabe5ed33f1e28e6aa49476 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,23 @@ bool WebSocketExtension::Equals(const WebSocketExtension& other) const {
return this_parameters == other_parameters;
}
+std::string WebSocketExtension::ToString() const {
+ if (name_.empty()) {
+ return std::string();
+ }
davidben 2015/09/22 19:44:02 Nit: no curlies
yhirano 2015/09/28 03:17:06 Done.
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698