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

Side by Side Diff: net/tools/testserver/run_testserver.cc

Issue 2901006: Add a run_testserver executable to make it easy to run the testserver... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months 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
« net/net.gyp ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdio.h>
6
7 #include "base/at_exit.h"
8 #include "base/command_line.h"
9 #include "base/message_loop.h"
10 #include "net/url_request/url_request_unittest.h"
11
12 static void PrintUsage() {
13 printf("run_testserver --doc-root=relpath [--http|--https|--ftp]\n");
14 printf("(NOTE: relpath should be relative to the 'src' directory)\n");
15 }
16
17 int main(int argc, const char* argv[]) {
18 base::AtExitManager at_exit_manager;
19 MessageLoopForIO message_loop;
20
21 // Process command line
22 CommandLine::Init(argc, argv);
23 CommandLine* command_line = CommandLine::ForCurrentProcess();
24
25 if (command_line->GetSwitchCount() == 0 ||
26 command_line->HasSwitch("help")) {
27 PrintUsage();
28 return -1;
29 }
30
31 std::string protocol;
32 int port;
33 if (command_line->HasSwitch("https")) {
34 protocol = "https";
35 port = net::TestServerLauncher::kOKHTTPSPort;
36 } else if (command_line->HasSwitch("ftp")) {
37 protocol = "ftp";
38 port = kFTPDefaultPort;
39 } else {
40 protocol = "http";
41 port = kHTTPDefaultPort;
42 }
43 std::wstring doc_root = command_line->GetSwitchValue("doc-root");
44 if (doc_root.empty()) {
45 printf("Error: --doc-root must be specified");
eroman 2010/07/09 18:36:14 typo: "Error".
46 PrintUsage();
47 return -1;
48 }
49
50 // Launch testserver
51 scoped_refptr<BaseTestServer> test_server;
52 if (protocol == "https") {
53 test_server = HTTPSTestServer::CreateGoodServer(doc_root);
54 } else if (protocol == "ftp") {
55 test_server = FTPTestServer::CreateServer(doc_root);
56 } else if (protocol == "http") {
57 test_server = HTTPTestServer::CreateServer(doc_root, NULL);
58 }
eroman 2010/07/09 18:36:14 nit: Can you add an else that is NOTREACHED() ?
59
60 printf("testserver running at %s://%s:%d (type ctrl+c to exit)\n",
61 protocol.c_str(),
eroman 2010/07/09 18:36:14 nit: Can you line this up with the open parenthesi
62 net::TestServerLauncher::kHostName,
63 port);
64
65 message_loop.Run();
66 return 0;
67 }
OLDNEW
« net/net.gyp ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698