HTTPCLIENT-911: improved handling of invalid request uris (host name containing an underscore)
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@909384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a2ff2dc9dd
commit
c5f52dc57d
|
@ -624,17 +624,21 @@ public abstract class AbstractHttpClient implements HttpClient {
|
|||
return execute(determineTarget(request), request, context);
|
||||
}
|
||||
|
||||
private HttpHost determineTarget(HttpUriRequest request) {
|
||||
private HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
|
||||
// A null target may be acceptable if there is a default target.
|
||||
// Otherwise, the null target is detected in the director.
|
||||
HttpHost target = null;
|
||||
|
||||
URI requestURI = request.getURI();
|
||||
if (requestURI.isAbsolute()) {
|
||||
target = new HttpHost(
|
||||
requestURI.getHost(),
|
||||
requestURI.getPort(),
|
||||
requestURI.getScheme());
|
||||
String host = requestURI.getHost();
|
||||
int port = requestURI.getPort();
|
||||
String scheme = requestURI.getScheme();
|
||||
if (host == null) {
|
||||
throw new ClientProtocolException(
|
||||
"URI does not specify a valid host name: " + requestURI);
|
||||
}
|
||||
target = new HttpHost(host, port, scheme);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue