| 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
|
|
|