| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 request_path = request_path.substr(0, query_pos); | 58 request_path = request_path.substr(0, query_pos); |
| 59 | 59 |
| 60 base::FilePath file_path(server_root.AppendASCII(request_path)); | 60 base::FilePath file_path(server_root.AppendASCII(request_path)); |
| 61 std::string file_contents; | 61 std::string file_contents; |
| 62 if (!file_util::ReadFileToString(file_path, &file_contents)) | 62 if (!file_util::ReadFileToString(file_path, &file_contents)) |
| 63 return scoped_ptr<HttpResponse>(); | 63 return scoped_ptr<HttpResponse>(); |
| 64 | 64 |
| 65 base::FilePath headers_path( | 65 base::FilePath headers_path( |
| 66 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers"))); | 66 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers"))); |
| 67 | 67 |
| 68 if (file_util::PathExists(headers_path)) { | 68 if (base::PathExists(headers_path)) { |
| 69 std::string headers_contents; | 69 std::string headers_contents; |
| 70 if (!file_util::ReadFileToString(headers_path, &headers_contents)) | 70 if (!file_util::ReadFileToString(headers_path, &headers_contents)) |
| 71 return scoped_ptr<HttpResponse>(); | 71 return scoped_ptr<HttpResponse>(); |
| 72 | 72 |
| 73 scoped_ptr<CustomHttpResponse> http_response( | 73 scoped_ptr<CustomHttpResponse> http_response( |
| 74 new CustomHttpResponse(headers_contents, file_contents)); | 74 new CustomHttpResponse(headers_contents, file_contents)); |
| 75 return http_response.PassAs<HttpResponse>(); | 75 return http_response.PassAs<HttpResponse>(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); | 78 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 std::map<StreamListenSocket*, HttpConnection*>::iterator it = | 267 std::map<StreamListenSocket*, HttpConnection*>::iterator it = |
| 268 connections_.find(socket); | 268 connections_.find(socket); |
| 269 if (it == connections_.end()) { | 269 if (it == connections_.end()) { |
| 270 return NULL; | 270 return NULL; |
| 271 } | 271 } |
| 272 return it->second; | 272 return it->second; |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace test_server | 275 } // namespace test_server |
| 276 } // namespace net | 276 } // namespace net |
| OLD | NEW |