Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test_http_server.cc

Issue 4667002: AU: Change test http server port from 8080 to 8088. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: whitespace Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « subprocess_unittest.cc ('k') | test_http_server.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 24 matching lines...) Expand all
35 35
36 struct HttpRequest { 36 struct HttpRequest {
37 HttpRequest() : offset(0), return_code(200) {} 37 HttpRequest() : offset(0), return_code(200) {}
38 string host; 38 string host;
39 string url; 39 string url;
40 off_t offset; 40 off_t offset;
41 int return_code; 41 int return_code;
42 }; 42 };
43 43
44 namespace { 44 namespace {
45 const int kPort = 8080; // hardcoded to 8080 for now 45 const int kPort = 8088; // hardcoded for now
46 const int kBigLength = 100000; 46 const int kBigLength = 100000;
47 const int kMediumLength = 1000; 47 const int kMediumLength = 1000;
48 } 48 }
49 49
50 bool ParseRequest(int fd, HttpRequest* request) { 50 bool ParseRequest(int fd, HttpRequest* request) {
51 string headers; 51 string headers;
52 while(headers.find("\r\n\r\n") == string::npos) { 52 while(headers.find("\r\n\r\n") == string::npos) {
53 vector<char> buf(1024); 53 vector<char> buf(1024);
54 memset(&buf[0], 0, buf.size()); 54 memset(&buf[0], 0, buf.size());
55 ssize_t r = read(fd, &buf[0], buf.size() - 1); 55 ssize_t r = read(fd, &buf[0], buf.size() - 1);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 close(fd); 255 close(fd);
256 } 256 }
257 257
258 } // namespace chromeos_update_engine 258 } // namespace chromeos_update_engine
259 259
260 using namespace chromeos_update_engine; 260 using namespace chromeos_update_engine;
261 261
262 int main(int argc, char** argv) { 262 int main(int argc, char** argv) {
263 // Ignore SIGPIPE on write() to sockets. 263 // Ignore SIGPIPE on write() to sockets.
264 signal(SIGPIPE, SIG_IGN); 264 signal(SIGPIPE, SIG_IGN);
265 265
266 socklen_t clilen; 266 socklen_t clilen;
267 struct sockaddr_in server_addr; 267 struct sockaddr_in server_addr;
268 struct sockaddr_in client_addr; 268 struct sockaddr_in client_addr;
269 memset(&server_addr, 0, sizeof(server_addr)); 269 memset(&server_addr, 0, sizeof(server_addr));
270 memset(&client_addr, 0, sizeof(client_addr)); 270 memset(&client_addr, 0, sizeof(client_addr));
271 271
272 int listen_fd = socket(AF_INET, SOCK_STREAM, 0); 272 int listen_fd = socket(AF_INET, SOCK_STREAM, 0);
273 if (listen_fd < 0) 273 if (listen_fd < 0)
274 LOG(FATAL) << "socket() failed"; 274 LOG(FATAL) << "socket() failed";
275 275
(...skipping 22 matching lines...) Expand all
298 int client_fd = accept(listen_fd, 298 int client_fd = accept(listen_fd,
299 (struct sockaddr *) &client_addr, 299 (struct sockaddr *) &client_addr,
300 &clilen); 300 &clilen);
301 LOG(INFO) << "got past accept"; 301 LOG(INFO) << "got past accept";
302 if (client_fd < 0) 302 if (client_fd < 0)
303 LOG(FATAL) << "ERROR on accept"; 303 LOG(FATAL) << "ERROR on accept";
304 HandleConnection(client_fd); 304 HandleConnection(client_fd);
305 } 305 }
306 return 0; 306 return 0;
307 } 307 }
OLDNEW
« no previous file with comments | « subprocess_unittest.cc ('k') | test_http_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698