Skip to content

Commit

Permalink
Fix case where rest client doesn't recognize the default port or https
Browse files Browse the repository at this point in the history
Fixes: quarkusio#16143
(cherry picked from commit 89fd2b0)
  • Loading branch information
geoand authored and gsmet committed Apr 3, 2021
1 parent 1da556b commit 047320f
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.RequestOptions;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -82,9 +83,15 @@ public void handle(Throwable event) {
public <T> HttpClientRequest createRequest(RestClientRequestContext state) {
HttpClient httpClient = state.getHttpClient();
URI uri = state.getUri();
HttpClientRequest httpClientRequest = httpClient.request(HttpMethod.valueOf(state.getHttpMethod()), uri.getPort(),
uri.getHost(),
uri.getPath() + (uri.getQuery() == null ? "" : "?" + uri.getQuery()));
boolean isHttps = "https".equals(uri.getScheme());
int port = uri.getPort() != -1 ? uri.getPort() : (isHttps ? 443 : 80);
HttpClientRequest httpClientRequest = httpClient.request(
HttpMethod.valueOf(state.getHttpMethod()),
new RequestOptions()
.setHost(uri.getHost())
.setURI(uri.getPath() + (uri.getQuery() == null ? "" : "?" + uri.getQuery()))
.setPort(port)
.setSsl(isHttps));
state.setHttpClientRequest(httpClientRequest);
return httpClientRequest;
}
Expand Down

0 comments on commit 047320f

Please sign in to comment.