diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java index 6c523e9fb76a..dc2dad00e719 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java @@ -108,7 +108,7 @@ public Mono connect(HttpMethod method, URI uri, HttpClient.RequestSender requestSender = this.httpClient .request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name())); - requestSender = (uri.isAbsolute() ? requestSender.uri(uri) : requestSender.uri(uri.toString())); + requestSender = setUri(requestSender, uri); return requestSender .send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound))) @@ -125,6 +125,18 @@ public Mono connect(HttpMethod method, URI uri, }); } + private static HttpClient.RequestSender setUri(HttpClient.RequestSender requestSender, URI uri) { + if (uri.isAbsolute()) { + try { + return requestSender.uri(uri); + } + catch (Exception ex) { + // Fall back on passing it in as a String + } + } + return requestSender.uri(uri.toString()); + } + private ReactorClientHttpRequest adaptRequest(HttpMethod method, URI uri, HttpClientRequest request, NettyOutbound nettyOutbound) {