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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Returns the base URL to the server, which looks like | 122 // Returns the base URL to the server, which looks like |
123 // http://127.0.0.1:<port>/, where <port> is the actual port number used by | 123 // http://127.0.0.1:<port>/, where <port> is the actual port number used by |
124 // the server. | 124 // the server. |
125 const GURL& base_url() const { return base_url_; } | 125 const GURL& base_url() const { return base_url_; } |
126 | 126 |
127 // Returns a URL to the server based on the given relative URL, which | 127 // Returns a URL to the server based on the given relative URL, which |
128 // should start with '/'. For example: GetURL("/path?query=foo") => | 128 // should start with '/'. For example: GetURL("/path?query=foo") => |
129 // http://127.0.0.1:<port>/path?query=foo. | 129 // http://127.0.0.1:<port>/path?query=foo. |
130 GURL GetURL(const std::string& relative_url) const; | 130 GURL GetURL(const std::string& relative_url) const; |
131 | 131 |
| 132 // Similar to the above method with the difference that it uses the supplied |
| 133 // |hostname| for the URL instead of 127.0.0.1. The hostname should be |
| 134 // resolved to 127.0.0.1. |
| 135 GURL GetURL(const std::string& hostname, |
| 136 const std::string& relative_url) const; |
| 137 |
132 // Returns the port number used by the server. | 138 // Returns the port number used by the server. |
133 int port() const { return port_; } | 139 int port() const { return port_; } |
134 | 140 |
135 // Registers request handler which serves files from |directory|. | 141 // Registers request handler which serves files from |directory|. |
136 // For instance, a request to "/foo.html" is served by "foo.html" under | 142 // For instance, a request to "/foo.html" is served by "foo.html" under |
137 // |directory|. Files under sub directories are also handled in the same way | 143 // |directory|. Files under sub directories are also handled in the same way |
138 // (i.e. "/foo/bar.html" is served by "foo/bar.html" under |directory|). | 144 // (i.e. "/foo/bar.html" is served by "foo/bar.html" under |directory|). |
139 void ServeFilesFromDirectory(const base::FilePath& directory); | 145 void ServeFilesFromDirectory(const base::FilePath& directory); |
140 | 146 |
141 // The most general purpose method. Any request processing can be added using | 147 // The most general purpose method. Any request processing can be added using |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // invalidate its weak pointers before any other members are destroyed. | 203 // invalidate its weak pointers before any other members are destroyed. |
198 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; | 204 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; |
199 | 205 |
200 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); | 206 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); |
201 }; | 207 }; |
202 | 208 |
203 } // namespace test_servers | 209 } // namespace test_servers |
204 } // namespace net | 210 } // namespace net |
205 | 211 |
206 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 212 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
OLD | NEW |