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 25 matching lines...) Expand all Loading... |
36 std::string request_path(request.relative_url.substr(1)); | 36 std::string request_path(request.relative_url.substr(1)); |
37 | 37 |
38 // Remove the query string if present. | 38 // Remove the query string if present. |
39 size_t query_pos = request_path.find('?'); | 39 size_t query_pos = request_path.find('?'); |
40 if (query_pos != std::string::npos) | 40 if (query_pos != std::string::npos) |
41 request_path = request_path.substr(0, query_pos); | 41 request_path = request_path.substr(0, query_pos); |
42 | 42 |
43 std::string file_contents; | 43 std::string file_contents; |
44 if (!file_util::ReadFileToString( | 44 if (!file_util::ReadFileToString( |
45 server_root.AppendASCII(request_path), &file_contents)) { | 45 server_root.AppendASCII(request_path), &file_contents)) { |
46 return scoped_ptr<HttpResponse>(NULL); | 46 return scoped_ptr<HttpResponse>(); |
47 } | 47 } |
48 | 48 |
49 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); | 49 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); |
50 http_response->set_code(net::test_server::SUCCESS); | 50 http_response->set_code(net::test_server::SUCCESS); |
51 http_response->set_content(file_contents); | 51 http_response->set_content(file_contents); |
52 return http_response.PassAs<HttpResponse>(); | 52 return http_response.PassAs<HttpResponse>(); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 std::map<StreamListenSocket*, HttpConnection*>::iterator it = | 238 std::map<StreamListenSocket*, HttpConnection*>::iterator it = |
239 connections_.find(socket); | 239 connections_.find(socket); |
240 if (it == connections_.end()) { | 240 if (it == connections_.end()) { |
241 return NULL; | 241 return NULL; |
242 } | 242 } |
243 return it->second; | 243 return it->second; |
244 } | 244 } |
245 | 245 |
246 } // namespace test_server | 246 } // namespace test_server |
247 } // namespace net | 247 } // namespace net |
OLD | NEW |