ceftests: Deprecate the use of test_server constants (see issue #3348)

This commit is contained in:
Marshall Greenblatt
2022-07-30 21:17:40 -04:00
parent 3269f1cd27
commit dd571c3318
10 changed files with 114 additions and 53 deletions

View File

@@ -11,10 +11,9 @@
namespace test_server {
// Must use a different port than server_unittest.cc.
const char kServerAddress[] = "127.0.0.1";
const uint16 kServerPort = 8098;
const char kServerScheme[] = "http";
const char kServerOrigin[] = "http://127.0.0.1:8098";
const char kHttpServerAddress[] = "127.0.0.1";
const uint16 kHttpServerPort = 8098;
const char kIncompleteDoNotSendData[] = "DO NOT SEND";
CefRefPtr<CefResponse> Create404Response() {
@@ -35,4 +34,24 @@ void Stop(base::OnceClosure callback) {
/*https_server=*/true);
}
std::string GetOrigin(bool https_server) {
return Manager::GetOrigin(https_server);
}
std::string GetScheme(bool https_server) {
return https_server ? "https" : "http";
}
std::string GetHost(bool https_server, bool include_port) {
const auto& origin = GetOrigin(https_server);
const auto scheme_offset = origin.find("//");
const auto& origin_without_scheme = origin.substr(scheme_offset + 2);
if (include_port)
return origin_without_scheme;
const auto port_offset = origin_without_scheme.find(':');
return origin_without_scheme.substr(0, port_offset);
}
} // namespace test_server