| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 // This file implements a simple HTTP server. It can exhibit odd behavior | 5 // This file implements a simple HTTP server. It can exhibit odd behavior |
| 6 // that's useful for testing. For example, it's useful to test that | 6 // that's useful for testing. For example, it's useful to test that |
| 7 // the updater can continue a connection if it's dropped, or that it | 7 // the updater can continue a connection if it's dropped, or that it |
| 8 // handles very slow data transfers. | 8 // handles very slow data transfers. |
| 9 | 9 |
| 10 // To use this, simply make an HTTP connection to localhost:port and | 10 // To use this, simply make an HTTP connection to localhost:port and |
| 11 // GET a url. | 11 // GET a url. |
| 12 | 12 |
| 13 #include <netinet/in.h> | 13 #include <netinet/in.h> |
| 14 #include <sys/socket.h> | 14 #include <sys/socket.h> |
| 15 #include <sys/types.h> | 15 #include <sys/types.h> |
| 16 #include <errno.h> | 16 #include <errno.h> |
| 17 #include <inttypes.h> | 17 #include <inttypes.h> |
| 18 #include <stdio.h> | 18 #include <stdio.h> |
| 19 #include <stdlib.h> | 19 #include <stdlib.h> |
| 20 #include <string.h> | 20 #include <string.h> |
| 21 #include <unistd.h> | 21 #include <unistd.h> |
| 22 #include <algorithm> | 22 #include <algorithm> |
| 23 #include <string> | 23 #include <string> |
| 24 #include <vector> | 24 #include <vector> |
| 25 #include "chromeos/obsolete_logging.h" | 25 #include "base/logging.h" |
| 26 | 26 |
| 27 using std::min; | 27 using std::min; |
| 28 using std::string; | 28 using std::string; |
| 29 using std::vector; | 29 using std::vector; |
| 30 | 30 |
| 31 namespace chromeos_update_engine { | 31 namespace chromeos_update_engine { |
| 32 | 32 |
| 33 struct HttpRequest { | 33 struct HttpRequest { |
| 34 HttpRequest() : offset(0), return_code(200) {} | 34 HttpRequest() : offset(0), return_code(200) {} |
| 35 string url; | 35 string url; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 int client_fd = accept(listen_fd, | 237 int client_fd = accept(listen_fd, |
| 238 (struct sockaddr *) &client_addr, | 238 (struct sockaddr *) &client_addr, |
| 239 &clilen); | 239 &clilen); |
| 240 LOG(INFO) << "got past accept"; | 240 LOG(INFO) << "got past accept"; |
| 241 if (client_fd < 0) | 241 if (client_fd < 0) |
| 242 LOG(FATAL) << "ERROR on accept"; | 242 LOG(FATAL) << "ERROR on accept"; |
| 243 HandleConnection(client_fd); | 243 HandleConnection(client_fd); |
| 244 } | 244 } |
| 245 return 0; | 245 return 0; |
| 246 } | 246 } |
| OLD | NEW |