OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 if (command_line->HasSwitch("https")) { | 105 if (command_line->HasSwitch("https")) { |
106 server_type = net::TestServer::TYPE_HTTPS; | 106 server_type = net::TestServer::TYPE_HTTPS; |
107 } else if (command_line->HasSwitch("ftp")) { | 107 } else if (command_line->HasSwitch("ftp")) { |
108 server_type = net::TestServer::TYPE_FTP; | 108 server_type = net::TestServer::TYPE_FTP; |
109 } else if (command_line->HasSwitch("sync")) { | 109 } else if (command_line->HasSwitch("sync")) { |
110 server_type = net::TestServer::TYPE_SYNC; | 110 server_type = net::TestServer::TYPE_SYNC; |
111 } else if (command_line->HasSwitch("sync-test")) { | 111 } else if (command_line->HasSwitch("sync-test")) { |
112 return RunSyncTest() ? 0 : -1; | 112 return RunSyncTest() ? 0 : -1; |
113 } | 113 } |
114 | 114 |
115 net::TestServer::HTTPSOptions https_options; | 115 net::TestServer::SSLOptions ssl_options; |
116 if (command_line->HasSwitch("https-cert")) { | 116 if (command_line->HasSwitch("https-cert")) { |
117 server_type = net::TestServer::TYPE_HTTPS; | 117 server_type = net::TestServer::TYPE_HTTPS; |
118 std::string cert_option = command_line->GetSwitchValueASCII("https-cert"); | 118 std::string cert_option = command_line->GetSwitchValueASCII("https-cert"); |
119 if (cert_option == "ok") { | 119 if (cert_option == "ok") { |
120 https_options.server_certificate = net::TestServer::HTTPSOptions::CERT_OK; | 120 ssl_options.server_certificate = net::TestServer::SSLOptions::CERT_OK; |
121 } else if (cert_option == "mismatched-name") { | 121 } else if (cert_option == "mismatched-name") { |
122 https_options.server_certificate = | 122 ssl_options.server_certificate = |
123 net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME; | 123 net::TestServer::SSLOptions::CERT_MISMATCHED_NAME; |
124 } else if (cert_option == "expired") { | 124 } else if (cert_option == "expired") { |
125 https_options.server_certificate = | 125 ssl_options.server_certificate = |
126 net::TestServer::HTTPSOptions::CERT_EXPIRED; | 126 net::TestServer::SSLOptions::CERT_EXPIRED; |
127 } else { | 127 } else { |
128 printf("Error: --https-cert has invalid value %s\n", cert_option.c_str()); | 128 printf("Error: --https-cert has invalid value %s\n", cert_option.c_str()); |
129 PrintUsage(); | 129 PrintUsage(); |
130 return -1; | 130 return -1; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 FilePath doc_root = command_line->GetSwitchValuePath("doc-root"); | 134 FilePath doc_root = command_line->GetSwitchValuePath("doc-root"); |
135 if ((server_type != net::TestServer::TYPE_SYNC) && doc_root.empty()) { | 135 if ((server_type != net::TestServer::TYPE_SYNC) && doc_root.empty()) { |
136 printf("Error: --doc-root must be specified\n"); | 136 printf("Error: --doc-root must be specified\n"); |
137 PrintUsage(); | 137 PrintUsage(); |
138 return -1; | 138 return -1; |
139 } | 139 } |
140 | 140 |
141 scoped_ptr<net::TestServer> test_server; | 141 scoped_ptr<net::TestServer> test_server; |
142 switch (server_type) { | 142 switch (server_type) { |
143 case net::TestServer::TYPE_HTTPS: { | 143 case net::TestServer::TYPE_HTTPS: { |
144 test_server.reset(new net::TestServer(https_options, doc_root)); | 144 test_server.reset(new net::TestServer(server_type, |
145 ssl_options, | |
146 doc_root)); | |
Ryan Sleevi
2012/08/22 09:21:16
nit: Is this line breaking needed? Looks like it f
Takashi Toyoshima
2012/08/22 13:39:16
Yeah, unfortunately it requires 81 characters with
| |
145 break; | 147 break; |
146 } | 148 } |
147 case net::TestServer::TYPE_SYNC: { | 149 case net::TestServer::TYPE_SYNC: { |
148 uint16 port = 0; | 150 uint16 port = 0; |
149 uint16 xmpp_port = 0; | 151 uint16 xmpp_port = 0; |
150 if (!GetPortFromSwitch("port", &port) || | 152 if (!GetPortFromSwitch("port", &port) || |
151 !GetPortFromSwitch("xmpp-port", &xmpp_port)) { | 153 !GetPortFromSwitch("xmpp-port", &xmpp_port)) { |
152 printf("Error: Could not extract --port and/or --xmpp-port.\n"); | 154 printf("Error: Could not extract --port and/or --xmpp-port.\n"); |
153 return -1; | 155 return -1; |
154 } | 156 } |
(...skipping 18 matching lines...) Expand all Loading... | |
173 UTF16ToUTF8(test_server->document_root().LossyDisplayName()).c_str()); | 175 UTF16ToUTF8(test_server->document_root().LossyDisplayName()).c_str()); |
174 return -1; | 176 return -1; |
175 } | 177 } |
176 | 178 |
177 printf("testserver running at %s (type ctrl+c to exit)\n", | 179 printf("testserver running at %s (type ctrl+c to exit)\n", |
178 test_server->host_port_pair().ToString().c_str()); | 180 test_server->host_port_pair().ToString().c_str()); |
179 | 181 |
180 message_loop.Run(); | 182 message_loop.Run(); |
181 return 0; | 183 return 0; |
182 } | 184 } |
OLD | NEW |