request.setHeader(HTTP.TARGET_HOST, "example.com");
url = RequestUtils.getRequestHostURL(request, null, null);
assertEquals("http://example.com", url);
ServerConfig serverConfig = new ServerConfig();
serverConfig.setParam("Port", "8080");
ServiceUrl serviceUrl = new ServiceUrl(serverConfig);
url = RequestUtils.getRequestHostURL(request, null, serviceUrl);
assertEquals("http://example.com:8080", url.toString());
serverConfig = new ServerConfig();
serverConfig.setParam("Port", "443");
serverConfig.setParam("https", "true");
serviceUrl = new ServiceUrl(serverConfig);
url = RequestUtils.getRequestHostURL(request, null, serviceUrl);
assertEquals("https://example.com", url.toString());
}