Chromium Code Reviews| 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); | |
|
stgao
2014/09/20 02:10:04
Why we don't have to close the connection now? Is
| |
| 91 } | 90 } |
| 92 | 91 |
| 93 HttpRequestHandlerFunc handle_request_func_; | 92 HttpRequestHandlerFunc handle_request_func_; |
| 94 scoped_ptr<net::HttpServer> server_; | 93 scoped_ptr<net::HttpServer> server_; |
| 95 base::WeakPtrFactory<HttpServer> weak_factory_; // Should be last. | 94 base::WeakPtrFactory<HttpServer> weak_factory_; // Should be last. |
| 96 }; | 95 }; |
| 97 | 96 |
| 98 void SendResponseOnCmdThread( | 97 void SendResponseOnCmdThread( |
| 99 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 98 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 100 const HttpResponseSenderFunc& send_response_on_io_func, | 99 const HttpResponseSenderFunc& send_response_on_io_func, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 } | 301 } |
| 303 | 302 |
| 304 if (!InitLogging()) { | 303 if (!InitLogging()) { |
| 305 printf("Unable to initialize logging. Exiting...\n"); | 304 printf("Unable to initialize logging. Exiting...\n"); |
| 306 return 1; | 305 return 1; |
| 307 } | 306 } |
| 308 RunServer(port, allow_remote, whitelisted_ips, | 307 RunServer(port, allow_remote, whitelisted_ips, |
| 309 url_base, adb_port, port_server.Pass()); | 308 url_base, adb_port, port_server.Pass()); |
| 310 return 0; | 309 return 0; |
| 311 } | 310 } |
| OLD | NEW |