Skip to content

Commit 8a67808

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent cdeb468 commit 8a67808

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

src/main/java/com/ning/http/client/ProxyServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ProxyServer(final Protocol protocol, final String host, final int port, S
6363
this.port = port;
6464
this.principal = principal;
6565
this.password = password;
66-
uri = AsyncHttpProviderUtils.createUri(toString());
66+
uri = AsyncHttpProviderUtils.createNonEmptyPathURI(toString());
6767
}
6868

6969
public ProxyServer(final String host, final int port, String principal, String password) {

src/main/java/com/ning/http/client/RequestBuilderBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public File getFile() {
298298
}
299299

300300
public boolean isRedirectEnabled() {
301-
return (followRedirects != null && followRedirects);
301+
return followRedirects != null && followRedirects;
302302
}
303303

304304
public boolean isRedirectOverrideSet() {

src/main/java/com/ning/http/client/providers/apache/ApacheAsyncHttpProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,9 @@ public T call() {
465465
try {
466466
URI uri = null;
467467
try {
468-
uri = AsyncHttpProviderUtils.createUri(request.getRawUrl());
468+
uri = AsyncHttpProviderUtils.createNonEmptyPathURI(request.getRawUrl());
469469
} catch (IllegalArgumentException u) {
470-
uri = AsyncHttpProviderUtils.createUri(request.getUrl());
470+
uri = AsyncHttpProviderUtils.createNonEmptyPathURI(request.getUrl());
471471
}
472472

473473
int delay = requestTimeout(config, future.getRequest().getPerRequestConfig());

src/main/java/com/ning/http/client/providers/jdk/JDKAsyncHttpProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ public T call() throws Exception {
231231
URI uri = null;
232232
// Encoding with URLConnection is a bit bogus so we need to try both way before setting it
233233
try {
234-
uri = AsyncHttpProviderUtils.createUri(request.getRawUrl());
234+
uri = AsyncHttpProviderUtils.createNonEmptyPathURI(request.getRawUrl());
235235
} catch (IllegalArgumentException u) {
236-
uri = AsyncHttpProviderUtils.createUri(request.getUrl());
236+
uri = AsyncHttpProviderUtils.createNonEmptyPathURI(request.getUrl());
237237
}
238238

239239
configure(uri, urlConnection, request);

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -995,12 +995,8 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
995995
boolean resultOfAConnect = f != null && f.getNettyRequest() != null && f.getNettyRequest().getMethod().equals(HttpMethod.CONNECT);
996996
boolean useProxy = proxyServer != null && !resultOfAConnect;
997997

998-
URI uri;
999-
if (useRawUrl) {
1000-
uri = request.getRawURI();
1001-
} else {
1002-
uri = request.getURI();
1003-
}
998+
URI uri = useRawUrl ? request.getRawURI() : request.getURI();
999+
10041000
ChannelBuffer bufferedBytes = null;
10051001
if (f != null && f.getRequest().getFile() == null && !f.getNettyRequest().getMethod().getName().equals(HttpMethod.CONNECT.getName())) {
10061002
bufferedBytes = f.getNettyRequest().getContent();

src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,22 @@ public static final void validateSupportedScheme(URI uri) {
5757
}
5858
}
5959

60-
public final static URI createUri(String u) {
60+
public final static URI createNonEmptyPathURI(String u) {
6161
URI uri = URI.create(u);
6262
validateSupportedScheme(uri);
6363

6464
String path = uri.getPath();
6565
if (path == null) {
66-
throw new IllegalArgumentException("The URI path, of the URI " + uri
67-
+ ", must be non-null");
66+
throw new IllegalArgumentException("The URI path, of the URI " + uri + ", must be non-null");
6867
} else if (isNonEmpty(path) && path.charAt(0) != '/') {
69-
throw new IllegalArgumentException("The URI path, of the URI " + uri
70-
+ ". must start with a '/'");
68+
throw new IllegalArgumentException("The URI path, of the URI " + uri + ". must start with a '/'");
7169
} else if (!isNonEmpty(path)) {
7270
return URI.create(u + "/");
7371
}
7472

7573
return uri;
7674
}
7775

78-
public static String getBaseUrl(String url) {
79-
return getBaseUrl(createUri(url));
80-
}
81-
8276
public final static String getBaseUrl(URI uri) {
8377
String url = uri.getScheme() + "://" + uri.getAuthority();
8478
int port = uri.getPort();

0 commit comments

Comments
 (0)