ServletCall.getHostDomain() simply returns the result of getServerName() from the HttpServletRequest without surrounding it with brackets.
Unfortunately, in combination with the HttpClient constructor, this results in cases where hostRef contains a malformed URL, since the hostRef URL is assembled by using StringBuilder (why?!) with everything concatenated without escaping.
This causes issues with Jetty 9 servlets and ServletAdapter, since HttpServletRequest.getServerName() there returns IPv6 addresses without any escaping.
For example, when accessing
http://[::1]:8888/api-path
references in HttpClient are actually set to
and later attempts to parse the URL fail with:
Can't parse hostPort : [hostRef,requestUri]=[null,http://::1:8888/api-path]
This can be fixed by changing either HttpClient or ServletCall to check for unbracketed IPv6 addresses and bracket them as necessary. I'm not sure which is the right way (the right right way, of course, being using java.net.URI for assembling URLs, and not that StringBuilder hack, but I assume you had reasons to do it this way). I'll make a pull request with ServletCall changed.
ServletCall.getHostDomain()simply returns the result ofgetServerName()from theHttpServletRequestwithout surrounding it with brackets.Unfortunately, in combination with the
HttpClientconstructor, this results in cases wherehostRefcontains a malformed URL, since thehostRefURL is assembled by usingStringBuilder(why?!) with everything concatenated without escaping.This causes issues with Jetty 9 servlets and
ServletAdapter, sinceHttpServletRequest.getServerName()there returns IPv6 addresses without any escaping.For example, when accessing
references in
HttpClientare actually set toand later attempts to parse the URL fail with:
This can be fixed by changing either
HttpClientorServletCallto check for unbracketed IPv6 addresses and bracket them as necessary. I'm not sure which is the right way (the right right way, of course, being usingjava.net.URIfor assembling URLs, and not thatStringBuilderhack, but I assume you had reasons to do it this way). I'll make a pull request withServletCallchanged.