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 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
6 #define NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 6 #define NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "net/base/ip_endpoint.h" | 25 #include "net/base/ip_endpoint.h" |
26 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
27 #include "net/socket/ssl_server_socket.h" | 27 #include "net/socket/ssl_server_socket.h" |
28 #include "net/socket/stream_socket.h" | 28 #include "net/socket/stream_socket.h" |
29 #include "net/socket/tcp_server_socket.h" | 29 #include "net/socket/tcp_server_socket.h" |
30 #include "net/ssl/ssl_server_config.h" | 30 #include "net/ssl/ssl_server_config.h" |
31 #include "url/gurl.h" | 31 #include "url/gurl.h" |
32 | 32 |
33 namespace net { | 33 namespace net { |
34 | 34 |
35 class ScopedPortException; | |
35 class StreamSocket; | 36 class StreamSocket; |
36 class TCPServerSocket; | 37 class TCPServerSocket; |
37 | 38 |
38 namespace test_server { | 39 namespace test_server { |
39 | 40 |
40 class EmbeddedTestServerConnectionListener; | 41 class EmbeddedTestServerConnectionListener; |
41 class HttpConnection; | 42 class HttpConnection; |
42 class HttpResponse; | 43 class HttpResponse; |
43 struct HttpRequest; | 44 struct HttpRequest; |
44 | 45 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // resolved to 127.0.0.1. | 171 // resolved to 127.0.0.1. |
171 GURL GetURL(const std::string& hostname, | 172 GURL GetURL(const std::string& hostname, |
172 const std::string& relative_url) const; | 173 const std::string& relative_url) const; |
173 | 174 |
174 // Returns the address list needed to connect to the server. | 175 // Returns the address list needed to connect to the server. |
175 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; | 176 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; |
176 | 177 |
177 // Returns the port number used by the server. | 178 // Returns the port number used by the server. |
178 uint16_t port() const { return port_; } | 179 uint16_t port() const { return port_; } |
179 | 180 |
181 // If set to true, the port used by the server is added to the allowed ports | |
182 // exception list, which will let network requests succeed even if the port | |
183 // happens to be on the unsafe port list. | |
184 void SetPortExceptionEnabled(bool enabled); | |
185 | |
180 void SetSSLConfig(ServerCertificate cert, const SSLServerConfig& ssl_config); | 186 void SetSSLConfig(ServerCertificate cert, const SSLServerConfig& ssl_config); |
181 void SetSSLConfig(ServerCertificate cert); | 187 void SetSSLConfig(ServerCertificate cert); |
182 | 188 |
183 // Returns the file name of the certificate the server is using. The test | 189 // Returns the file name of the certificate the server is using. The test |
184 // certificates can be found in net/data/ssl/certificates/. | 190 // certificates can be found in net/data/ssl/certificates/. |
185 std::string GetCertificateName() const; | 191 std::string GetCertificateName() const; |
186 | 192 |
187 // Returns the certificate that the server is using. | 193 // Returns the certificate that the server is using. |
188 scoped_refptr<X509Certificate> GetCertificate() const; | 194 scoped_refptr<X509Certificate> GetCertificate() const; |
189 | 195 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 | 280 |
275 std::unique_ptr<base::Thread> io_thread_; | 281 std::unique_ptr<base::Thread> io_thread_; |
276 | 282 |
277 std::unique_ptr<TCPServerSocket> listen_socket_; | 283 std::unique_ptr<TCPServerSocket> listen_socket_; |
278 std::unique_ptr<StreamSocket> accepted_socket_; | 284 std::unique_ptr<StreamSocket> accepted_socket_; |
279 | 285 |
280 EmbeddedTestServerConnectionListener* connection_listener_; | 286 EmbeddedTestServerConnectionListener* connection_listener_; |
281 uint16_t port_; | 287 uint16_t port_; |
282 GURL base_url_; | 288 GURL base_url_; |
283 IPEndPoint local_endpoint_; | 289 IPEndPoint local_endpoint_; |
290 std::unique_ptr<ScopedPortException> port_exception_; | |
284 | 291 |
285 std::map<StreamSocket*, std::unique_ptr<HttpConnection>> connections_; | 292 std::map<StreamSocket*, std::unique_ptr<HttpConnection>> connections_; |
286 | 293 |
287 // Vector of registered and default request handlers and monitors. | 294 // Vector of registered and default request handlers and monitors. |
288 std::vector<HandleRequestCallback> request_handlers_; | 295 std::vector<HandleRequestCallback> request_handlers_; |
289 std::vector<MonitorRequestCallback> request_monitors_; | 296 std::vector<MonitorRequestCallback> request_monitors_; |
290 std::vector<HandleRequestCallback> default_request_handlers_; | 297 std::vector<HandleRequestCallback> default_request_handlers_; |
291 | 298 |
292 base::ThreadChecker thread_checker_; | 299 base::ThreadChecker thread_checker_; |
293 | 300 |
294 net::SSLServerConfig ssl_config_; | 301 net::SSLServerConfig ssl_config_; |
295 ServerCertificate cert_; | 302 ServerCertificate cert_; |
296 std::unique_ptr<SSLServerContext> context_; | 303 std::unique_ptr<SSLServerContext> context_; |
297 | 304 |
298 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; | 305 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; |
299 | 306 |
307 | |
svaldez
2016/12/09 15:26:53
Stray?
rohitrao (ping after 24h)
2016/12/09 16:08:53
Done.
| |
300 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); | 308 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); |
301 }; | 309 }; |
302 | 310 |
303 } // namespace test_server | 311 } // namespace test_server |
304 | 312 |
305 // TODO(svaldez): Refactor EmbeddedTestServer to be in the net namespace. | 313 // TODO(svaldez): Refactor EmbeddedTestServer to be in the net namespace. |
306 using test_server::EmbeddedTestServer; | 314 using test_server::EmbeddedTestServer; |
307 | 315 |
308 } // namespace net | 316 } // namespace net |
309 | 317 |
310 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 318 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
OLD | NEW |