| Index: net/test/test_server.cc
|
| diff --git a/net/test/test_server.cc b/net/test/test_server.cc
|
| index 0e8c4611e4e0a3c4e16924abf0b4f0b9a9f5ff4f..1fd20c9fb12d6ea829a9771d5fd89b32d6d24274 100644
|
| --- a/net/test/test_server.cc
|
| +++ b/net/test/test_server.cc
|
| @@ -17,11 +17,14 @@
|
| #include "base/base64.h"
|
| #include "base/command_line.h"
|
| #include "base/debug/leak_annotations.h"
|
| +#include "base/json/json_reader.h"
|
| #include "base/file_util.h"
|
| #include "base/logging.h"
|
| #include "base/path_service.h"
|
| +#include "base/scoped_ptr.h"
|
| #include "base/string_number_conversions.h"
|
| #include "base/utf_string_conversions.h"
|
| +#include "base/values.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "net/base/cert_test_util.h"
|
| #include "net/base/host_port_pair.h"
|
| @@ -278,6 +281,11 @@ bool TestServer::SetPythonPath() {
|
| }
|
| third_party_dir = third_party_dir.Append(FILE_PATH_LITERAL("third_party"));
|
|
|
| + // For simplejson. (simplejson, unlike all the other python modules
|
| + // we include, doesn't have an extra 'simplejson' directory, so we
|
| + // need to include its parent directory, i.e. third_party_dir).
|
| + AppendToPythonPath(third_party_dir);
|
| +
|
| AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("tlslite")));
|
| AppendToPythonPath(third_party_dir.Append(FILE_PATH_LITERAL("pyftpdlib")));
|
|
|
| @@ -373,4 +381,28 @@ bool TestServer::AddCommandLineArguments(CommandLine* command_line) const {
|
| return true;
|
| }
|
|
|
| +bool TestServer::ParseServerData(const std::string& server_data) {
|
| + VLOG(1) << "Server data: " << server_data;
|
| + base::JSONReader json_reader;
|
| + scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, false));
|
| + if (!value.get() ||
|
| + !value->IsType(Value::TYPE_DICTIONARY)) {
|
| + LOG(ERROR) << "Could not parse server data: "
|
| + << json_reader.GetErrorMessage();
|
| + return false;
|
| + }
|
| + DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
|
| + int port = 0;
|
| + if (!dict->GetInteger("port", &port)) {
|
| + LOG(ERROR) << "Could not find port value";
|
| + return false;
|
| + }
|
| + if ((port <= 0) || (port >= kuint16max)) {
|
| + LOG(ERROR) << "Invalid port value: " << port;
|
| + return false;
|
| + }
|
| + host_port_pair_.set_port(port);
|
| + return true;
|
| +}
|
| +
|
| } // namespace net
|
|
|