Skip to content

Commit 34fa953

Browse files
author
Stephane Landelle
committed
Fix invalidUri test, crappy url format should be supported
1 parent d4ec320 commit 34fa953

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.ning.http.client.Request.EntityWriter;
2121
import com.ning.http.util.AsyncHttpProviderUtils;
2222
import com.ning.http.util.UTF8UrlEncoder;
23+
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
2526

@@ -374,6 +375,8 @@ public T setUrl(String url) {
374375
}
375376

376377
public T setURI(URI uri) {
378+
if (uri.getPath() == null)
379+
throw new IllegalArgumentException("Unsupported uri format: " + uri);
377380
request.originalUri = uri;
378381
addQueryParameters(request.originalUri);
379382
request.uri = null;

src/test/java/com/ning/http/client/async/AsyncProvidersBasicTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,13 +1666,11 @@ protected String getBrokenTargetUrl() {
16661666
return String.format("http:127.0.0.1:%d/foo/test", port1);
16671667
}
16681668

1669-
@Test(groups = { "standalone", "default_provider" })
1669+
@Test(groups = { "standalone", "default_provider" }, expectedExceptions = { IllegalArgumentException.class })
16701670
public void invalidUri() throws Exception {
16711671
AsyncHttpClient client = getAsyncHttpClient(null);
16721672
try {
1673-
AsyncHttpClient.BoundRequestBuilder builder = client.prepareGet(getBrokenTargetUrl());
1674-
Response r = client.executeRequest(builder.build()).get();
1675-
assertEquals(200, r.getStatusCode());
1673+
client.prepareGet(getBrokenTargetUrl());
16761674
} finally {
16771675
client.close();
16781676
}

0 commit comments

Comments
 (0)