Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ning/async-http-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Dudziak committed Jul 26, 2010
2 parents efbd0f0 + 32d757b commit efc6c15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -462,7 +462,8 @@ private <T> Future<T> doConnect(final Request request, final AsyncHandler<T> asy
}


if (config.getMaxTotalConnections() != -1 && activeConnectionsCount.getAndIncrement()>= config.getMaxTotalConnections()) {
if (config.getMaxTotalConnections() != -1 && activeConnectionsCount.getAndIncrement() >= config.getMaxTotalConnections()) {
activeConnectionsCount.decrementAndGet();
throw new IOException("Too many connections");
}

Expand Down Expand Up @@ -648,6 +649,7 @@ private void markAsDoneAndCacheConnection(final NettyResponseFuture<?> future, f
if (connectionPerHost.getAndIncrement() < config.getMaxConnectionPerHost()) {
connectionsPool.put(getBaseUrl(future.getURI()), channel);
} else {
connectionPerHost.decrementAndGet();
log.warn("Maximum connections per hosts reached " + config.getMaxConnectionPerHost());
}
} else {
Expand All @@ -663,7 +665,7 @@ private String getBaseUrl(URI uri){
port = getPort(uri);
url = url.substring(0,url.length() -1) + ":" + port;
}
return url.substring(0,url.lastIndexOf(":") + String.valueOf(port).length() +1);
return url.substring(0,url.indexOf(":", 9) + String.valueOf(port).length() +1);
}

private static int getPort(URI uri) {
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/ning/http/client/async/ComplexClientTest.java
Expand Up @@ -118,4 +118,15 @@ public void urlWithoutSlashTest() throws Throwable {

assertEquals(response.getResponseBody(),body);
}

@Test(groups = "standalone")
public void urlWithColonTest() throws Throwable {
AsyncHttpClient c = new AsyncHttpClient();

String query = "q=test:colon:";
Response response = c.prepareGet(String.format("http://127.0.0.1:%d/foo/test/colon?%s", port1, query))
.execute().get(TIMEOUT, TimeUnit.SECONDS);

assertEquals(response.getHeader("X-queryString"), query);
}
}

0 comments on commit efc6c15

Please sign in to comment.