| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/test/test_server.h" | 5 #include "net/test/test_server.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | |
| 13 // static | |
| 14 void TestServer::AppendToPythonPath(const FilePath& dir) { | |
| 15 const char kPythonPath[] = "PYTHONPATH"; | |
| 16 const char* oldpath = getenv(kPythonPath); | |
| 17 // setenv() leaks memory intentionally on Mac | |
| 18 if (!oldpath) { | |
| 19 setenv(kPythonPath, dir.value().c_str(), 1); | |
| 20 } else if (!strstr(oldpath, dir.value().c_str())) { | |
| 21 std::string newpath(oldpath); | |
| 22 newpath.append(":"); | |
| 23 newpath.append(dir.value()); | |
| 24 setenv(kPythonPath, newpath.c_str(), 1); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 bool TestServer::LaunchPython(const FilePath& testserver_path) { | 12 bool TestServer::LaunchPython(const FilePath& testserver_path) { |
| 29 std::vector<std::string> command_line; | 13 std::vector<std::string> command_line; |
| 30 command_line.push_back("python"); | 14 command_line.push_back("python"); |
| 31 command_line.push_back(testserver_path.value()); | 15 command_line.push_back(testserver_path.value()); |
| 32 command_line.push_back("--port=" + base::IntToString(host_port_pair_.port())); | 16 command_line.push_back("--port=" + base::IntToString(host_port_pair_.port())); |
| 33 command_line.push_back("--data-dir=" + document_root_.value()); | 17 command_line.push_back("--data-dir=" + document_root_.value()); |
| 34 | 18 |
| 35 if (type_ == TYPE_FTP) | 19 if (type_ == TYPE_FTP) |
| 36 command_line.push_back("-f"); | 20 command_line.push_back("-f"); |
| 37 | 21 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 } | 39 } |
| 56 | 40 |
| 57 return true; | 41 return true; |
| 58 } | 42 } |
| 59 | 43 |
| 60 bool TestServer::CheckCATrusted() { | 44 bool TestServer::CheckCATrusted() { |
| 61 return true; | 45 return true; |
| 62 } | 46 } |
| 63 | 47 |
| 64 } // namespace net | 48 } // namespace net |
| OLD | NEW |