Skip to content

Commit 1d5392e

Browse files
author
Stephane Landelle
committed
Remove useless calls to Request.getUrl, close AsyncHttpClient#582
1 parent a898855 commit 1d5392e

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

api/src/main/java/org/asynchttpclient/resumable/ResumableAsyncHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ public AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) throws
197197
*/
198198
public Request adjustRequestRange(Request request) {
199199

200-
if (resumableIndex.get(request.getUrl()) != null) {
201-
byteTransferred.set(resumableIndex.get(request.getUrl()));
200+
Long ri = resumableIndex.get(request.getUrl());
201+
if (ri != null) {
202+
byteTransferred.set(ri);
202203
}
203204

204205
// The Resumbale

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ protected void initChannel(Channel ch) throws Exception {
296296
});
297297
}
298298

299-
public Bootstrap getBootstrap(String url, boolean useSSl, boolean useProxy) {
300-
return (url.startsWith(WEBSOCKET) && !useProxy) ? (useSSl ? secureWebSocketBootstrap : webSocketBootstrap)
299+
public Bootstrap getBootstrap(URI uri, boolean useSSl, boolean useProxy) {
300+
return (uri.getScheme().startsWith(WEBSOCKET) && !useProxy) ? (useSSl ? secureWebSocketBootstrap : webSocketBootstrap)
301301
: (useSSl ? secureBootstrap : plainBootstrap);
302302
}
303303

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private boolean handleUnauthorizedAndExit(int statusCode, Realm realm, final Req
257257
Realm nr = new Realm.RealmBuilder().clone(newRealm).setUri(realmURI).build();
258258
final Request nextRequest = new RequestBuilder(future.getRequest()).setHeaders(request.getHeaders()).setRealm(nr).build();
259259

260-
LOGGER.debug("Sending authentication to {}", request.getUrl());
260+
LOGGER.debug("Sending authentication to {}", request.getURI());
261261
Callback callback = new Callback(future) {
262262
public void call() throws Exception {
263263
channels.drainChannel(channel, future);
@@ -302,7 +302,7 @@ private boolean handleProxyAuthenticationRequiredAndExit(int statusCode,//
302302
if (statusCode == PROXY_AUTHENTICATION_REQUIRED.code() && realm != null) {
303303
List<String> proxyAuthenticateHeaders = response.headers().getAll(HttpHeaders.Names.PROXY_AUTHENTICATE);
304304
if (!proxyAuthenticateHeaders.isEmpty() && !future.getAndSetAuth(true)) {
305-
LOGGER.debug("Sending proxy authentication to {}", request.getUrl());
305+
LOGGER.debug("Sending proxy authentication to {}", request.getURI());
306306

307307
future.setState(NettyResponseFuture.STATE.NEW);
308308
Realm newRealm = null;
@@ -346,10 +346,9 @@ private boolean handleConnectOKAndExit(int statusCode, Realm realm, final Reques
346346
}
347347

348348
try {
349-
LOGGER.debug("Connecting to proxy {} for scheme {}", proxyServer, request.getUrl());
350-
351349
URI requestURI = request.getURI();
352350
String scheme = requestURI.getScheme();
351+
LOGGER.debug("Connecting to proxy {} for scheme {}", proxyServer, scheme);
353352
String host = AsyncHttpProviderUtils.getHost(requestURI);
354353
int port = AsyncHttpProviderUtils.getPort(requestURI);
355354

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected boolean handleRedirectAndExit(Request request, NettyResponseFuture<?>
117117

118118
future.setURI(uri);
119119
String newUrl = uri.toString();
120-
if (request.getUrl().startsWith(WEBSOCKET)) {
120+
if (request.getURI().getScheme().startsWith(WEBSOCKET)) {
121121
newUrl = newUrl.replaceFirst(HTTP, WEBSOCKET);
122122
}
123123

providers/netty/src/main/java/org/asynchttpclient/providers/netty/request/NettyRequestSender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private <T> ListenableFuture<T> sendRequestWithNewChannel(//
219219
// Do not throw an exception when we need an extra connection for a redirect
220220
// FIXME why? This violate the max connection per host handling, right?
221221
boolean acquiredConnection = !reclaimCache && channels.acquireConnection(asyncHandler);
222-
Bootstrap bootstrap = channels.getBootstrap(request.getUrl(), useSSl, useProxy);
222+
Bootstrap bootstrap = channels.getBootstrap(request.getURI(), useSSl, useProxy);
223223

224224
NettyConnectListener<T> connectListener = new NettyConnectListener<T>(config, this, future);
225225

@@ -349,7 +349,7 @@ public <T> ListenableFuture<T> sendRequest(final Request request,//
349349
}
350350

351351
// FIXME really useful? Why not do this check when building the request?
352-
if (request.getUrl().startsWith(WEBSOCKET) && !validateWebSocketRequest(request, asyncHandler)) {
352+
if (request.getURI().getScheme().startsWith(WEBSOCKET) && !validateWebSocketRequest(request, asyncHandler)) {
353353
throw new IOException("WebSocket method must be a GET");
354354
}
355355

0 commit comments

Comments
 (0)