| Index: net/http/http_server_properties.cc
|
| diff --git a/net/http/http_server_properties.cc b/net/http/http_server_properties.cc
|
| index 15947b2a49e9dbb1bcbe1195953aa4d8587c37ea..fb19ffb873ea1cbbe768630a8e42456dacfe46aa 100644
|
| --- a/net/http/http_server_properties.cc
|
| +++ b/net/http/http_server_properties.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram_macros.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "net/socket/ssl_client_socket.h"
|
| #include "net/ssl/ssl_config.h"
|
| @@ -102,6 +103,29 @@ std::string AlternativeService::ToString() const {
|
| host.c_str(), port);
|
| }
|
|
|
| +bool AlternativeService::FromString(const std::string& str,
|
| + AlternativeService* alternative_service) {
|
| + size_t space_pos = str.find(' ');
|
| + if (space_pos == std::string::npos)
|
| + return false;
|
| + size_t colon_pos = str.find(':');
|
| + if (colon_pos == std::string::npos)
|
| + return false;
|
| +
|
| + alternative_service->protocol = NextProtoFromString(str.substr(0, space_pos));
|
| + alternative_service->host =
|
| + str.substr(space_pos + 1, colon_pos - space_pos - 1);
|
| +
|
| + unsigned port_uint;
|
| + if (!base::StringToUint(str.substr(colon_pos + 1), &port_uint))
|
| + return false;
|
| + if (port_uint > std::numeric_limits<uint16_t>::max())
|
| + return false;
|
| + alternative_service->port = (uint16_t)port_uint;
|
| +
|
| + return true;
|
| +}
|
| +
|
| std::string AlternativeServiceInfo::ToString() const {
|
| base::Time::Exploded exploded;
|
| expiration_.LocalExplode(&exploded);
|
|
|