-
Notifications
You must be signed in to change notification settings - Fork 278
Description
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
http://::1:8888/api-path
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.