Skip to content

Commits on Source 7

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
language: java
sudo: false
jdk:
- openjdk7
- oraclejdk8
after_success:
- mvn clean cobertura:cobertura coveralls:report
Release 4.1.3
Release 4.1.4
-------------------
This is a maintenance release that fixes a number of minor issues discovered since 4.1.2 and upgrades
HttpCore and HttpClient dependencies.
This is a maintenance release that adds Automatic-Module-Name to the manifest for compatibility
with Java 9 Platform Module System and fixes a number of issues discovered since 4.1.3
Changelog
-------------------
* Add Automatic-Module-Name in manifest so Java9 modular applications can depend on this library.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* Upgraded HttpCore dependency to version 4.4.10; upgraded HttpClient dependency to version 4.5.6.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* Pass the original request as a parameter to the redirect handler.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPASYNC-135] HttpAsyncMethods.createHead() methods creates HttpGet objects.
Contributed by Mateusz Matela <mateusz dot matela at gmail dot>
* [HTTPASYNC-136]: Failing tests on Fedora 28 due to weak encryption algorithms in test keystore.
Contributed by Gary Gregory <ggregory at apache.org> and Michael Simacek <msimacek at redhat dot com>
* [HTTPASYNC-126] Increase range of commons-logging in OSGI manifest
* [HTTPASYNC-118] HttpAsyncClientBuilder to use SystemDefaultCredentialsProvider by default when configured
to use system properties.
Contributed by Oleg Kalnichevski <olegk at apache.org>
Release 4.1.3
-------------------
Changelog
-------------------
......
httpcomponents-asyncclient (4.1.4-1) unstable; urgency=medium
* Team upload.
* New upstream release
* Standards-Version updated to 4.2.1
* Switch to debhelper level 11
* Use salsa.debian.org Vcs-* URLs
-- Emmanuel Bourg <ebourg@apache.org> Fri, 19 Oct 2018 15:23:55 +0200
httpcomponents-asyncclient (4.1.3-1) unstable; urgency=medium
* Team upload.
......
......@@ -3,7 +3,8 @@ Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Emmanuel Bourg <ebourg@apache.org>
Build-Depends: debhelper (>= 10),
Build-Depends:
debhelper (>= 11),
default-jdk,
junit4,
libbuild-helper-maven-plugin-java,
......@@ -13,9 +14,9 @@ Build-Depends: debhelper (>= 10),
libhttpcore-java,
libmockito-java,
maven-debian-helper (>= 2.0)
Standards-Version: 3.9.8
Vcs-Git: https://anonscm.debian.org/git/pkg-java/httpcomponents-asyncclient.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/httpcomponents-asyncclient.git
Standards-Version: 4.2.1
Vcs-Git: https://salsa.debian.org/java-team/httpcomponents-asyncclient.git
Vcs-Browser: https://salsa.debian.org/java-team/httpcomponents-asyncclient
Homepage: http://hc.apache.org/httpcomponents-asyncclient-dev
Package: libhttpasyncclient-java
......
......@@ -2,6 +2,3 @@
%:
dh $@
get-orig-source:
uscan --download-current-version --force-download --no-symlink
......@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-asyncclient</artifactId>
<version>4.1.3</version>
<version>4.1.4</version>
</parent>
<artifactId>httpasyncclient-cache</artifactId>
<name>Apache HttpAsyncClient Cache</name>
......@@ -88,6 +88,28 @@
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive combine.children="append">
<manifestEntries>
<Automatic-Module-Name>org.apache.httpcomponents.httpasyncclient.cache</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
......
......@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-asyncclient</artifactId>
<version>4.1.3</version>
<version>4.1.4</version>
</parent>
<artifactId>httpasyncclient-osgi</artifactId>
<name>Apache HttpAsyncClient OSGi bundle</name>
......@@ -41,7 +41,7 @@
<properties>
<httpcore.osgi.import.version>"[4.4.0, 4.5.0)"</httpcore.osgi.import.version>
<httpclient.osgi.import.version>"[4.5.0, 4.6.0)"</httpclient.osgi.import.version>
<commons-logging.osgi.import.version>"[1.1.0, 1.2.0)"</commons-logging.osgi.import.version>
<commons-logging.osgi.import.version>"[1.1.0, 1.3.0)"</commons-logging.osgi.import.version>
</properties>
<dependencies>
......
......@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-asyncclient</artifactId>
<version>4.1.3</version>
<version>4.1.4</version>
</parent>
<artifactId>httpasyncclient</artifactId>
<name>Apache HttpAsyncClient</name>
......@@ -106,6 +106,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive combine.children="append">
<manifestEntries>
<Automatic-Module-Name>org.apache.httpcomponents.httpasyncclient</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
......@@ -117,19 +117,19 @@ public class QuickStart {
@Override
public void completed(final HttpResponse response3) {
latch2.countDown();
System.out.println(request2.getRequestLine() + "->" + response3.getStatusLine());
System.out.println(request3.getRequestLine() + "->" + response3.getStatusLine());
}
@Override
public void failed(final Exception ex) {
latch2.countDown();
System.out.println(request2.getRequestLine() + "->" + ex);
System.out.println(request3.getRequestLine() + "->" + ex);
}
@Override
public void cancelled() {
latch2.countDown();
System.out.println(request2.getRequestLine() + " cancelled");
System.out.println(request3.getRequestLine() + " cancelled");
}
});
......
......@@ -80,6 +80,7 @@ import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.impl.client.NoopUserTokenHandler;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.http.impl.client.SystemDefaultCredentialsProvider;
import org.apache.http.impl.client.TargetAuthenticationStrategy;
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
import org.apache.http.impl.conn.DefaultRoutePlanner;
......@@ -831,9 +832,12 @@ public class HttpAsyncClientBuilder {
CredentialsProvider defaultCredentialsProvider = this.credentialsProvider;
if (defaultCredentialsProvider == null) {
if (systemProperties) {
defaultCredentialsProvider = new SystemDefaultCredentialsProvider();
} else {
defaultCredentialsProvider = new BasicCredentialsProvider();
}
}
RedirectStrategy redirectStrategy = this.redirectStrategy;
if (redirectStrategy == null) {
redirectStrategy = DefaultRedirectStrategy.INSTANCE;
......
......@@ -580,7 +580,7 @@ class MainClientExec implements InternalClientExec {
}
}
if (config.isRedirectsEnabled()) {
final HttpRequest currentRequest = handler.getCurrentRequest();
final HttpRequestWrapper currentRequest = handler.getCurrentRequest();
final HttpResponse currentResponse = handler.getCurrentResponse();
if (this.redirectStrategy.isRedirected(currentRequest, currentResponse, localContext)) {
final int maxRedirects = config.getMaxRedirects() >= 0 ? config.getMaxRedirects() : 100;
......@@ -588,7 +588,7 @@ class MainClientExec implements InternalClientExec {
throw new RedirectException("Maximum redirects (" + maxRedirects + ") exceeded");
}
state.incrementRedirectCount();
final HttpUriRequest redirect = this.redirectStrategy.getRedirect(currentRequest, currentResponse,
final HttpUriRequest redirect = this.redirectStrategy.getRedirect(currentRequest.getOriginal(), currentResponse,
localContext);
state.setRedirect(redirect);
return true;
......
......@@ -118,7 +118,7 @@ public class PoolingNHttpClientConnectionManager
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final Registry<SchemeIOSessionStrategy> iosessionFactoryRegistry) {
this(ioreactor, null, iosessionFactoryRegistry, null);
this(ioreactor, null, iosessionFactoryRegistry, (DnsResolver) null);
}
public PoolingNHttpClientConnectionManager(
......@@ -128,17 +128,24 @@ public class PoolingNHttpClientConnectionManager
this(ioreactor, connFactory, getDefaultRegistry(), dnsResolver);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
final SocketAddressResolver<HttpRoute> socketAddressResolver) {
this(ioreactor, connFactory, getDefaultRegistry(), socketAddressResolver);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory) {
this(ioreactor, connFactory, getDefaultRegistry(), null);
this(ioreactor, connFactory, getDefaultRegistry(), (DnsResolver) null);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
final Registry<SchemeIOSessionStrategy> iosessionFactoryRegistry) {
this(ioreactor, connFactory, iosessionFactoryRegistry, null);
this(ioreactor, connFactory, iosessionFactoryRegistry, (DnsResolver) null);
}
public PoolingNHttpClientConnectionManager(
......@@ -150,6 +157,15 @@ public class PoolingNHttpClientConnectionManager
-1, TimeUnit.MILLISECONDS);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
final Registry<SchemeIOSessionStrategy> iosessionFactoryRegistry,
final SocketAddressResolver<HttpRoute> socketAddressResolver) {
this(ioreactor, connFactory, iosessionFactoryRegistry, socketAddressResolver,
-1, TimeUnit.MILLISECONDS);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
......@@ -157,14 +173,25 @@ public class PoolingNHttpClientConnectionManager
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
final long timeToLive, final TimeUnit tunit) {
this(ioreactor, connFactory, iosessionFactoryRegistry,
new InternalAddressResolver(schemePortResolver, dnsResolver), timeToLive, tunit);
}
public PoolingNHttpClientConnectionManager(
final ConnectingIOReactor ioreactor,
final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
final Registry<SchemeIOSessionStrategy> iosessionFactoryRegistry,
final SocketAddressResolver<HttpRoute> socketAddressResolver,
final long timeToLive, final TimeUnit tunit) {
super();
Args.notNull(ioreactor, "I/O reactor");
Args.notNull(iosessionFactoryRegistry, "I/O session factory registry");
Args.notNull(socketAddressResolver, "Socket address resolver");
this.ioreactor = ioreactor;
this.configData = new ConfigData();
this.pool = new CPool(ioreactor,
new InternalConnectionFactory(this.configData, connFactory),
new InternalAddressResolver(schemePortResolver, dnsResolver),
socketAddressResolver,
2, 20, timeToLive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
this.iosessionFactoryRegistry = iosessionFactoryRegistry;
}
......
......@@ -37,6 +37,7 @@ import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
......@@ -112,7 +113,7 @@ public final class HttpAsyncMethods {
* @return asynchronous request generator
*/
public static HttpAsyncRequestProducer createHead(final URI requestURI) {
return create(new HttpGet(requestURI));
return create(new HttpHead(requestURI));
}
/**
......@@ -122,7 +123,7 @@ public final class HttpAsyncMethods {
* @return asynchronous request generator
*/
public static HttpAsyncRequestProducer createHead(final String requestURI) {
return create(new HttpGet(URI.create(requestURI)));
return create(new HttpHead(URI.create(requestURI)));
}
/**
......
......@@ -29,6 +29,7 @@ package org.apache.http.impl.nio.conn;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Calendar;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
......@@ -234,7 +235,7 @@ public class TestPoolingHttpClientAsyncConnectionManager {
future.get();
}
@Test
@Test(expected = CancellationException.class)
public void testRequestConnectionCancelled() throws Exception {
final HttpHost target = new HttpHost("localhost");
final HttpRoute route = new HttpRoute(target);
......@@ -254,7 +255,7 @@ public class TestPoolingHttpClientAsyncConnectionManager {
Assert.assertTrue(future.isDone());
Assert.assertTrue(future.isCancelled());
Assert.assertNull(future.get());
future.get();
}
@Test
......
......@@ -27,6 +27,7 @@
package org.apache.http.nio.client.integration;
import java.io.IOException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
......@@ -382,7 +383,11 @@ public class TestHttpAsyncPrematureTermination extends HttpAsyncTestBase {
};
final Future<?> future = this.httpclient.execute(producer, consumer, null, null);
try {
future.get();
Assert.fail("CancellationException expected");
} catch (final CancellationException expected) {
}
connMgr.shutdown(1000);
......
......@@ -40,6 +40,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.http.Header;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.localserver.HttpAsyncTestBase;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
......@@ -269,6 +270,49 @@ public class TestRedirects extends HttpAsyncTestBase {
}
}
private static class DifferentHostRedirectService implements HttpRequestHandler {
private final String schemeName;
private final int statusCode;
private int targetHostPort;
public DifferentHostRedirectService(final String schemeName, final int statusCode) {
this.schemeName = schemeName;
this.statusCode = statusCode;
}
@Override
public void handle(final HttpRequest request, final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
final String uri = request.getRequestLine().getUri();
if (uri.equals("/oldlocation/")) {
final String redirectUrl =
this.schemeName + "://localhost:" + targetHostPort + "/newlocation/";
response.setStatusLine(ver, this.statusCode);
response.addHeader(new BasicHeader("Location", redirectUrl));
response.addHeader(new BasicHeader("Connection", "close"));
} else if (uri.equals("/newlocation/")) {
final String hostHeaderValue = request.getFirstHeader("Host").getValue();
if (hostHeaderValue.equals("localhost:" + targetHostPort)) {
response.setStatusLine(ver, HttpStatus.SC_OK);
final StringEntity entity = new StringEntity("Successful redirect");
response.setEntity(entity);
} else {
response.setStatusLine(ver, 421, "Misdirected Request");
}
} else {
response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
}
}
public void setTargetHostPort(final int targetHostPort) {
this.targetHostPort = targetHostPort;
}
}
@Test
public void testBasicRedirect300() throws Exception {
this.serverBootstrap.registerHandler("*", new BasicAsyncRequestHandler(
......@@ -853,4 +897,43 @@ public class TestRedirects extends HttpAsyncTestBase {
Assert.assertEquals(host, target);
}
@Test
public void testPostRedirectWithDifferentHost() throws Exception {
// do redirect for post requests
this.clientBuilder.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
public boolean isRedirected(final HttpRequest request, final HttpResponse response,
final HttpContext context)
throws ProtocolException {
// allow 307 redirect for all methods
return super.isRedirected(request, response, context)
|| response.getStatusLine().getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT;
}
});
final DifferentHostRedirectService differentHostRequestHandler = new DifferentHostRedirectService(
getSchemeName(), HttpStatus.SC_TEMPORARY_REDIRECT);
this.serverBootstrap.registerHandler("*",
new BasicAsyncRequestHandler(differentHostRequestHandler));
final HttpHost originalHost = start(); // to start the original host and build the client
final HttpHost targetHost = startServer(); // to start the target host
differentHostRequestHandler.setTargetHostPort(targetHost.getPort());
final HttpClientContext context = HttpClientContext.create();
final HttpPost httpPost = new HttpPost("/oldlocation/");
final Future<HttpResponse> future = this.httpclient.execute(originalHost, httpPost, context, null);
final HttpResponse response = future.get();
Assert.assertNotNull(response);
final HttpRequest reqWrapper = context.getRequest();
final HttpHost host = context.getTargetHost();
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
Assert.assertEquals(targetHost, host);
}
}
......@@ -33,7 +33,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>httpcomponents-asyncclient</artifactId>
<name>Apache HttpComponents AsyncClient</name>
<version>4.1.3</version>
<version>4.1.4</version>
<description>Apache components to build asynchronous client side HTTP services</description>
<url>http://hc.apache.org/httpcomponents-asyncclient</url>
<inceptionYear>2010</inceptionYear>
......@@ -47,7 +47,7 @@
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>LICENSE.txt</url>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
......@@ -58,16 +58,16 @@
</issueManagement>
<scm>
<connection>scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/tags/4.1.3</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/tags/4.1.3</developerConnection>
<url>https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/tags/4.1.3</url>
<connection>scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/branches/4.1.x</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/branches/4.1.x</developerConnection>
<url>https://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/branches/4.1.x</url>
</scm>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<httpcore.version>4.4.6</httpcore.version>
<httpclient.version>4.5.3</httpclient.version>
<httpcore.version>4.4.10</httpcore.version>
<httpclient.version>4.5.6</httpclient.version>
<commons-logging.version>1.2</commons-logging.version>
<commons-io.version>2.4</commons-io.version>
<junit.version>4.11</junit.version>
......