Skip to content

Commit 0628194

Browse files
wsargentStephane Landelle
authored andcommitted
Use AsyncHttpProviderUtils.getHost/getPort (avoids -1 for default port problem)
1 parent 5a7880d commit 0628194

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.asynchttpclient.Request;
2323
import org.asynchttpclient.providers.netty.channel.Channels;
2424
import org.asynchttpclient.providers.netty.request.NettyRequestSender;
25+
import org.asynchttpclient.util.AsyncHttpProviderUtils;
2526
import org.slf4j.Logger;
2627
import org.slf4j.LoggerFactory;
2728

@@ -73,7 +74,9 @@ public void close() {
7374
@Override
7475
public <T> ListenableFuture<T> execute(Request request, final AsyncHandler<T> asyncHandler) throws IOException {
7576
final URI uri = request.getURI();
76-
channels.configureProcessor(requestSender, closed, uri.getHost(), uri.getPort());
77+
final String host = AsyncHttpProviderUtils.getHost(uri);
78+
final int port = AsyncHttpProviderUtils.getPort(uri);
79+
channels.configureProcessor(requestSender, closed, host, port);
7780

7881
return requestSender.sendRequest(request, asyncHandler, null, false);
7982
}

providers/netty/src/main/java/org/asynchttpclient/providers/netty/channel/Channels.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.asynchttpclient.providers.netty.handler.Processor;
3333
import org.asynchttpclient.providers.netty.request.NettyRequestSender;
3434
import org.asynchttpclient.providers.netty.util.CleanupChannelGroup;
35+
import org.asynchttpclient.util.AsyncHttpProviderUtils;
3536
import org.asynchttpclient.util.SslUtils;
3637
import org.slf4j.Logger;
3738
import org.slf4j.LoggerFactory;
@@ -374,7 +375,9 @@ public Channel pollAndVerifyCachedChannel(URI uri, ProxyServer proxy, Connection
374375
LOGGER.debug("Using cached Channel {}\n for uri {}\n", channel, uri);
375376

376377
try {
377-
verifyChannelPipeline(channel.pipeline(), uri.getScheme(), uri.getHost(), uri.getPort());
378+
final String host = AsyncHttpProviderUtils.getHost(uri);
379+
final int port = AsyncHttpProviderUtils.getPort(uri);
380+
verifyChannelPipeline(channel.pipeline(), uri.getScheme(), host, port);
378381
} catch (Exception ex) {
379382
LOGGER.debug(ex.getMessage(), ex);
380383
}

providers/netty/src/main/java/org/asynchttpclient/providers/netty/handler/HttpProtocol.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ private boolean handleConnectOKAndExit(int statusCode, Realm realm, final Reques
320320

321321
try {
322322
LOGGER.debug("Connecting to proxy {} for scheme {}", proxyServer, request.getUrl());
323-
URI uri = request.getURI();
324-
channels.upgradeProtocol(channel.pipeline(), uri.getScheme(), uri.getHost(), uri.getPort());
323+
final URI uri = request.getURI();
324+
final String host = AsyncHttpProviderUtils.getHost(uri);
325+
final int port = AsyncHttpProviderUtils.getPort(uri);
326+
channels.upgradeProtocol(channel.pipeline(), uri.getScheme(), host, port);
325327
} catch (Throwable ex) {
326328
channels.abort(future, ex);
327329
}

0 commit comments

Comments
 (0)