* Examples: http://localhost:2468 or http://somehostname:3000
*
* @since 1.14.3.1
*/
protected String getRequestURLBase() {
WebServer ws = getTinyWebServer();
// get the host that was used to make this request from the http headers
String fullHostAndPort = (String) env.get("HTTP_HOST");
if (StringUtils.hasValue(fullHostAndPort))
return "http://" + fullHostAndPort;
// if the http request did not contain a host header, reconstruct the
// host and port from other values at our disposal.
String host = (String) env.get("SERVER_ADDR");
if (!StringUtils.hasValue(host))
host = ws.getHostName(true);
// get the port number that the server is listening on
int port = ws.getPort();
// return the appropriate value
return "http://" + host + ":" + port;
}