| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <locale> | 6 #include <locale> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual void OnClose(int connection_id) OVERRIDE {} | 80 virtual void OnClose(int connection_id) OVERRIDE {} |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 void OnResponse(int connection_id, | 83 void OnResponse(int connection_id, |
| 84 scoped_ptr<net::HttpServerResponseInfo> response) { | 84 scoped_ptr<net::HttpServerResponseInfo> response) { |
| 85 // Don't support keep-alive, since there's no way to detect if the | 85 // Don't support keep-alive, since there's no way to detect if the |
| 86 // client is HTTP/1.0. In such cases, the client may hang waiting for | 86 // client is HTTP/1.0. In such cases, the client may hang waiting for |
| 87 // the connection to close (e.g., python 2.7 urllib). | 87 // the connection to close (e.g., python 2.7 urllib). |
| 88 response->AddHeader("Connection", "close"); | 88 response->AddHeader("Connection", "close"); |
| 89 server_->SendResponse(connection_id, *response); | 89 server_->SendResponse(connection_id, *response); |
| 90 server_->Close(connection_id); | 90 // Don't need to call server_->Close(), since SendResponse() will handle |
| 91 // this for us. |
| 91 } | 92 } |
| 92 | 93 |
| 93 HttpRequestHandlerFunc handle_request_func_; | 94 HttpRequestHandlerFunc handle_request_func_; |
| 94 scoped_ptr<net::HttpServer> server_; | 95 scoped_ptr<net::HttpServer> server_; |
| 95 base::WeakPtrFactory<HttpServer> weak_factory_; // Should be last. | 96 base::WeakPtrFactory<HttpServer> weak_factory_; // Should be last. |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 void SendResponseOnCmdThread( | 99 void SendResponseOnCmdThread( |
| 99 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 100 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 100 const HttpResponseSenderFunc& send_response_on_io_func, | 101 const HttpResponseSenderFunc& send_response_on_io_func, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 303 } |
| 303 | 304 |
| 304 if (!InitLogging()) { | 305 if (!InitLogging()) { |
| 305 printf("Unable to initialize logging. Exiting...\n"); | 306 printf("Unable to initialize logging. Exiting...\n"); |
| 306 return 1; | 307 return 1; |
| 307 } | 308 } |
| 308 RunServer(port, allow_remote, whitelisted_ips, | 309 RunServer(port, allow_remote, whitelisted_ips, |
| 309 url_base, adb_port, port_server.Pass()); | 310 url_base, adb_port, port_server.Pass()); |
| 310 return 0; | 311 return 0; |
| 311 } | 312 } |
| OLD | NEW |