You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2019/07/14 12:13:30 UTC
[httpcomponents-client] 02/03: Deprecated HttpClient functionality
now provided out of HttpCore
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch httpcore-5.0b8-upgrade
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit eb7392121746751b0d0e0290f68feaa1da7445dc
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Jun 6 16:55:38 2019 +0200
Deprecated HttpClient functionality now provided out of HttpCore
---
.../http/impl/cache/BasicHttpAsyncCache.java | 6 +-
.../hc/client5/http/impl/cache/BasicHttpCache.java | 6 +-
.../org/apache/hc/client5/http/fluent/Request.java | 4 +-
.../async/AbstractHttpAsyncFundamentalsTest.java | 14 +-
.../testing/async/TestHttpAsyncMinimal.java | 9 +-
.../apache/hc/client5/http/StandardMethods.java | 3 +
.../http/async/methods/AsyncRequestBuilder.java | 84 +++---
.../client5/http/async/methods/HttpRequests.java | 34 +--
.../http/async/methods/SimpleHttpRequest.java | 6 +-
.../http/async/methods/SimpleHttpRequests.java | 34 +--
.../http/classic/methods/RequestBuilder.java | 3 +
.../http/impl/DefaultHttpRequestRetryHandler.java | 4 +-
.../client5/http/impl/async/AsyncProtocolExec.java | 4 +-
.../client5/http/impl/async/AsyncRedirectExec.java | 6 +-
.../hc/client5/http/impl/classic/ProtocolExec.java | 4 +-
.../hc/client5/http/impl/classic/RedirectExec.java | 9 +-
.../client5/http/ssl/ClientTlsStrategyBuilder.java | 1 +
.../ssl/SSLConnectionSocketFactoryBuilder.java | 1 +
.../java/org/apache/hc/client5/http/ssl/TLS.java | 10 +-
.../hc/client5/http/ssl/TlsSessionValidator.java | 1 +
.../hc/client5/http/ssl/TlsVersionParser.java | 105 --------
.../async/methods/TestAsyncRequestBuilder.java | 42 ---
.../http/classic/methods/TestRequestBuilder.java | 296 ---------------------
.../http/examples/AsyncClientHttp2ServerPush.java | 5 +-
.../examples/AsyncClientHttpExchangeStreaming.java | 5 +-
.../http/examples/AsyncClientMessageTrailers.java | 2 +-
.../hc/client5/http/examples/AsyncQuickStart.java | 2 +-
.../hc/client5/http/examples/ClientCustomSSL.java | 2 +-
.../hc/client5/http/examples/ClientFormLogin.java | 4 +-
.../impl/classic/TestContentCompressionExec.java | 20 +-
.../hc/client5/http/ssl/TestTlsVersionParser.java | 93 -------
31 files changed, 148 insertions(+), 671 deletions(-)
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
index f936bc1..9494d2f 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
@@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.cache.HeaderConstants;
import org.apache.hc.client5.http.cache.HttpAsyncCacheInvalidator;
import org.apache.hc.client5.http.cache.HttpAsyncCacheStorage;
@@ -48,6 +47,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer;
@@ -100,7 +100,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) {
log.debug("Flush cache entries: " + host + "; " + new RequestLine(request));
}
- if (!StandardMethods.isSafe(request.getMethod())) {
+ if (!Methods.isSafe(request.getMethod())) {
final String cacheKey = cacheKeyGenerator.generateKey(host, request);
return storage.removeEntry(cacheKey, new FutureCallback<Boolean>() {
@@ -147,7 +147,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) {
log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response));
}
- if (!StandardMethods.isSafe(request.getMethod())) {
+ if (!Methods.isSafe(request.getMethod())) {
return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback);
}
callback.completed(Boolean.TRUE);
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
index 8343e94..14b3638 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
@@ -30,7 +30,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.cache.HeaderConstants;
import org.apache.hc.client5.http.cache.HttpCacheCASOperation;
import org.apache.hc.client5.http.cache.HttpCacheEntry;
@@ -43,6 +42,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer;
@@ -102,7 +102,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) {
log.debug("Flush cache entries: " + host + "; " + new RequestLine(request));
}
- if (!StandardMethods.isSafe(request.getMethod())) {
+ if (!Methods.isSafe(request.getMethod())) {
final String cacheKey = cacheKeyGenerator.generateKey(host, request);
try {
storage.removeEntry(cacheKey);
@@ -127,7 +127,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) {
log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response));
}
- if (!StandardMethods.isSafe(request.getMethod())) {
+ if (!Methods.isSafe(request.getMethod())) {
cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage);
}
}
diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
index 850ef6b..339abee 100644
--- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
+++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
@@ -41,7 +41,6 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.classic.methods.ClassicHttpRequests;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.client5.http.config.Configurable;
@@ -56,6 +55,7 @@ import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.io.entity.FileEntity;
@@ -81,7 +81,7 @@ public class Request {
private SimpleDateFormat dateFormatter;
- public static Request create(final StandardMethods method, final URI uri) {
+ public static Request create(final Methods method, final URI uri) {
return new Request(new HttpUriRequestBase(method.name(), uri));
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
index 281609e..33a47f2 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
@@ -36,7 +36,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequests;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
@@ -46,8 +45,11 @@ import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Message;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers;
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer;
+import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
@@ -96,9 +98,8 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final Random rnd = new Random(System.currentTimeMillis());
rnd.nextBytes(b1);
final Future<Message<HttpResponse, byte[]>> future = httpclient.execute(
- AsyncRequestBuilder.post(target, "/echo/")
- .setEntity(b1, ContentType.APPLICATION_OCTET_STREAM)
- .build(),
+ new BasicRequestProducer(Methods.GET, target, "/echo/",
+ AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
final Message<HttpResponse, byte[]> responseMessage = future.get();
Assert.assertThat(responseMessage, CoreMatchers.notNullValue());
@@ -121,9 +122,8 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>();
for (int i = 0; i < reqCount; i++) {
final Future<Message<HttpResponse, byte[]>> future = httpclient.execute(
- AsyncRequestBuilder.post(target, "/echo/")
- .setEntity(b1, ContentType.APPLICATION_OCTET_STREAM)
- .build(),
+ new BasicRequestProducer(Methods.POST, target, "/echo/",
+ AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future);
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java
index 8bdd5b5..23eb5f0 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java
@@ -34,7 +34,6 @@ import java.util.Random;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.client5.http.impl.async.MinimalHttpAsyncClient;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
@@ -47,10 +46,13 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.Message;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
+import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers;
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer;
+import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
@@ -122,9 +124,8 @@ public class TestHttpAsyncMinimal extends AbstractHttpAsyncFundamentalsTest<Mini
final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>();
for (int i = 0; i < reqCount; i++) {
final Future<Message<HttpResponse, byte[]>> future = endpoint.execute(
- AsyncRequestBuilder.post(target, "/echo/")
- .setEntity(b1, ContentType.APPLICATION_OCTET_STREAM)
- .build(),
+ new BasicRequestProducer(Methods.GET, target, "/echo/",
+ AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future);
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/StandardMethods.java b/httpclient5/src/main/java/org/apache/hc/client5/http/StandardMethods.java
index 305dc73..39ba814 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/StandardMethods.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/StandardMethods.java
@@ -33,7 +33,10 @@ import java.util.Locale;
* Common HTTP methods defined by the HTTP spec.
*
* @since 5.0
+ *
+ * @deprecated Use {@link org.apache.hc.core5.http.Methods}
*/
+@Deprecated
public enum StandardMethods {
GET(true, true),
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
index 33d5f62..91a6f4f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java
@@ -35,11 +35,11 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.message.BasicHeader;
@@ -66,7 +66,10 @@ import org.apache.hc.core5.util.TextUtils;
* </p>
*
* @since 5.0
+ *
+ * @deprecated Use {@link org.apache.hc.core5.http.nio.support.AsyncRequestBuilder}
*/
+@Deprecated
public class AsyncRequestBuilder {
private HttpHost host;
@@ -88,7 +91,7 @@ public class AsyncRequestBuilder {
this.method = method;
}
- AsyncRequestBuilder(final StandardMethods method) {
+ AsyncRequestBuilder(final Methods method) {
this(method.name());
}
@@ -98,18 +101,18 @@ public class AsyncRequestBuilder {
this.uri = uri;
}
- AsyncRequestBuilder(final StandardMethods method, final HttpHost host, final String path) {
+ AsyncRequestBuilder(final Methods method, final HttpHost host, final String path) {
super();
this.method = method.name();
this.host = host;
this.path = path;
}
- AsyncRequestBuilder(final StandardMethods method, final URI uri) {
+ AsyncRequestBuilder(final Methods method, final URI uri) {
this(method.name(), uri);
}
- AsyncRequestBuilder(final StandardMethods method, final String uri) {
+ AsyncRequestBuilder(final Methods method, final String uri) {
this(method.name(), uri != null ? URI.create(uri) : null);
}
@@ -123,131 +126,131 @@ public class AsyncRequestBuilder {
}
public static AsyncRequestBuilder get() {
- return new AsyncRequestBuilder(StandardMethods.GET);
+ return new AsyncRequestBuilder(Methods.GET);
}
public static AsyncRequestBuilder get(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.GET, uri);
+ return new AsyncRequestBuilder(Methods.GET, uri);
}
public static AsyncRequestBuilder get(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.GET, uri);
+ return new AsyncRequestBuilder(Methods.GET, uri);
}
public static AsyncRequestBuilder get(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.GET, host, path);
+ return new AsyncRequestBuilder(Methods.GET, host, path);
}
public static AsyncRequestBuilder head() {
- return new AsyncRequestBuilder(StandardMethods.HEAD);
+ return new AsyncRequestBuilder(Methods.HEAD);
}
public static AsyncRequestBuilder head(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.HEAD, uri);
+ return new AsyncRequestBuilder(Methods.HEAD, uri);
}
public static AsyncRequestBuilder head(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.HEAD, uri);
+ return new AsyncRequestBuilder(Methods.HEAD, uri);
}
public static AsyncRequestBuilder head(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.HEAD, host, path);
+ return new AsyncRequestBuilder(Methods.HEAD, host, path);
}
public static AsyncRequestBuilder patch() {
- return new AsyncRequestBuilder(StandardMethods.PATCH);
+ return new AsyncRequestBuilder(Methods.PATCH);
}
public static AsyncRequestBuilder patch(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.PATCH, uri);
+ return new AsyncRequestBuilder(Methods.PATCH, uri);
}
public static AsyncRequestBuilder patch(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.PATCH, uri);
+ return new AsyncRequestBuilder(Methods.PATCH, uri);
}
public static AsyncRequestBuilder patch(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.PATCH, host, path);
+ return new AsyncRequestBuilder(Methods.PATCH, host, path);
}
public static AsyncRequestBuilder post() {
- return new AsyncRequestBuilder(StandardMethods.POST);
+ return new AsyncRequestBuilder(Methods.POST);
}
public static AsyncRequestBuilder post(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.POST, uri);
+ return new AsyncRequestBuilder(Methods.POST, uri);
}
public static AsyncRequestBuilder post(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.POST, uri);
+ return new AsyncRequestBuilder(Methods.POST, uri);
}
public static AsyncRequestBuilder post(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.POST, host, path);
+ return new AsyncRequestBuilder(Methods.POST, host, path);
}
public static AsyncRequestBuilder put() {
- return new AsyncRequestBuilder(StandardMethods.PUT);
+ return new AsyncRequestBuilder(Methods.PUT);
}
public static AsyncRequestBuilder put(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.PUT, uri);
+ return new AsyncRequestBuilder(Methods.PUT, uri);
}
public static AsyncRequestBuilder put(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.PUT, uri);
+ return new AsyncRequestBuilder(Methods.PUT, uri);
}
public static AsyncRequestBuilder put(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.PUT, host, path);
+ return new AsyncRequestBuilder(Methods.PUT, host, path);
}
public static AsyncRequestBuilder delete() {
- return new AsyncRequestBuilder(StandardMethods.DELETE);
+ return new AsyncRequestBuilder(Methods.DELETE);
}
public static AsyncRequestBuilder delete(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.DELETE, uri);
+ return new AsyncRequestBuilder(Methods.DELETE, uri);
}
public static AsyncRequestBuilder delete(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.DELETE, uri);
+ return new AsyncRequestBuilder(Methods.DELETE, uri);
}
public static AsyncRequestBuilder delete(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.DELETE, host, path);
+ return new AsyncRequestBuilder(Methods.DELETE, host, path);
}
public static AsyncRequestBuilder trace() {
- return new AsyncRequestBuilder(StandardMethods.TRACE);
+ return new AsyncRequestBuilder(Methods.TRACE);
}
public static AsyncRequestBuilder trace(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.TRACE, uri);
+ return new AsyncRequestBuilder(Methods.TRACE, uri);
}
public static AsyncRequestBuilder trace(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.TRACE, uri);
+ return new AsyncRequestBuilder(Methods.TRACE, uri);
}
public static AsyncRequestBuilder trace(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.TRACE, host, path);
+ return new AsyncRequestBuilder(Methods.TRACE, host, path);
}
public static AsyncRequestBuilder options() {
- return new AsyncRequestBuilder(StandardMethods.OPTIONS);
+ return new AsyncRequestBuilder(Methods.OPTIONS);
}
public static AsyncRequestBuilder options(final URI uri) {
- return new AsyncRequestBuilder(StandardMethods.OPTIONS, uri);
+ return new AsyncRequestBuilder(Methods.OPTIONS, uri);
}
public static AsyncRequestBuilder options(final String uri) {
- return new AsyncRequestBuilder(StandardMethods.OPTIONS, uri);
+ return new AsyncRequestBuilder(Methods.OPTIONS, uri);
}
public static AsyncRequestBuilder options(final HttpHost host, final String path) {
- return new AsyncRequestBuilder(StandardMethods.OPTIONS, host, path);
+ return new AsyncRequestBuilder(Methods.OPTIONS, host, path);
}
public AsyncRequestBuilder setCharset(final Charset charset) {
@@ -411,8 +414,7 @@ public class AsyncRequestBuilder {
public AsyncRequestProducer build() {
AsyncEntityProducer entityProducerCopy = this.entityProducer;
if (parameters != null && !parameters.isEmpty()) {
- if (entityProducerCopy == null && (StandardMethods.POST.name().equalsIgnoreCase(method)
- || StandardMethods.PUT.name().equalsIgnoreCase(method))) {
+ if (entityProducerCopy == null && (Methods.POST.isSame(method) || Methods.PUT.isSame(method))) {
final String content = URLEncodedUtils.format(
parameters,
charset != null ? charset : ContentType.APPLICATION_FORM_URLENCODED.getCharset());
@@ -431,8 +433,8 @@ public class AsyncRequestBuilder {
}
}
- if (entityProducerCopy != null && StandardMethods.TRACE.name().equalsIgnoreCase(method)) {
- throw new IllegalStateException(StandardMethods.TRACE.name() + " requests may not include an entity.");
+ if (entityProducerCopy != null && Methods.isSafe(method)) {
+ throw new IllegalStateException(Methods.TRACE + " requests may not include an entity.");
}
final ConfigurableHttpRequest request = host != null ?
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java
index 056b80b..436eee8 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java
@@ -29,8 +29,8 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.message.BasicHttpRequest;
/**
@@ -43,96 +43,96 @@ public enum HttpRequests {
DELETE {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.DELETE.name(), uri);
+ return new BasicHttpRequest(Methods.DELETE, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.DELETE.name(), host, path);
+ return new BasicHttpRequest(Methods.DELETE, host, path);
}
},
GET {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.GET.name(), uri);
+ return new BasicHttpRequest(Methods.GET, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.GET.name(), host, path);
+ return new BasicHttpRequest(Methods.GET, host, path);
}
},
HEAD {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.HEAD.name(), uri);
+ return new BasicHttpRequest(Methods.HEAD, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.HEAD.name(), host, path);
+ return new BasicHttpRequest(Methods.HEAD, host, path);
}
},
OPTIONS {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.OPTIONS.name(), uri);
+ return new BasicHttpRequest(Methods.OPTIONS, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.OPTIONS.name(), host, path);
+ return new BasicHttpRequest(Methods.OPTIONS, host, path);
}
},
PATCH {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.PATCH.name(), uri);
+ return new BasicHttpRequest(Methods.PATCH, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.PATCH.name(), host, path);
+ return new BasicHttpRequest(Methods.PATCH, host, path);
}
},
POST {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.POST.name(), uri);
+ return new BasicHttpRequest(Methods.POST, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.POST.name(), host, path);
+ return new BasicHttpRequest(Methods.POST, host, path);
}
},
PUT {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.PUT.name(), uri);
+ return new BasicHttpRequest(Methods.PUT, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.PUT.name(), host, path);
+ return new BasicHttpRequest(Methods.PUT, host, path);
}
},
TRACE {
@Override
public BasicHttpRequest create(final URI uri) {
- return new BasicHttpRequest(StandardMethods.TRACE.name(), uri);
+ return new BasicHttpRequest(Methods.TRACE, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
- return new BasicHttpRequest(StandardMethods.TRACE.name(), host, path);
+ return new BasicHttpRequest(Methods.TRACE, host, path);
}
};
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
index 51306e5..efb63de 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java
@@ -30,11 +30,11 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI;
import java.util.Iterator;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.util.Args;
/**
@@ -73,11 +73,11 @@ public final class SimpleHttpRequest extends ConfigurableHttpRequest {
super(method, requestUri);
}
- SimpleHttpRequest(final StandardMethods method, final URI requestUri) {
+ SimpleHttpRequest(final Methods method, final URI requestUri) {
this(method.name(), requestUri);
}
- SimpleHttpRequest(final StandardMethods method, final HttpHost host, final String path) {
+ SimpleHttpRequest(final Methods method, final HttpHost host, final String path) {
this(method.name(), host, path);
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java
index f5dd6c8..13f5d7e 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java
@@ -29,8 +29,8 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.Methods;
/**
* Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation.
@@ -42,96 +42,96 @@ public enum SimpleHttpRequests {
DELETE {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.DELETE.name(), uri);
+ return new SimpleHttpRequest(Methods.DELETE, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.DELETE.name(), host, path);
+ return new SimpleHttpRequest(Methods.DELETE, host, path);
}
},
GET {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.GET.name(), uri);
+ return new SimpleHttpRequest(Methods.GET, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.GET.name(), host, path);
+ return new SimpleHttpRequest(Methods.GET, host, path);
}
},
HEAD {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.HEAD.name(), uri);
+ return new SimpleHttpRequest(Methods.HEAD, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.HEAD.name(), host, path);
+ return new SimpleHttpRequest(Methods.HEAD, host, path);
}
},
OPTIONS {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.OPTIONS.name(), uri);
+ return new SimpleHttpRequest(Methods.OPTIONS, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.OPTIONS.name(), host, path);
+ return new SimpleHttpRequest(Methods.OPTIONS, host, path);
}
},
PATCH {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.PATCH.name(), uri);
+ return new SimpleHttpRequest(Methods.PATCH, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.PATCH.name(), host, path);
+ return new SimpleHttpRequest(Methods.PATCH, host, path);
}
},
POST {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.POST.name(), uri);
+ return new SimpleHttpRequest(Methods.POST, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.POST.name(), host, path);
+ return new SimpleHttpRequest(Methods.POST, host, path);
}
},
PUT {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.PUT.name(), uri);
+ return new SimpleHttpRequest(Methods.PUT, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.PUT.name(), host, path);
+ return new SimpleHttpRequest(Methods.PUT, host, path);
}
},
TRACE {
@Override
public SimpleHttpRequest create(final URI uri) {
- return new SimpleHttpRequest(StandardMethods.TRACE.name(), uri);
+ return new SimpleHttpRequest(Methods.TRACE, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
- return new SimpleHttpRequest(StandardMethods.TRACE.name(), host, path);
+ return new SimpleHttpRequest(Methods.TRACE, host, path);
}
};
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java
index cc6aad2..3f8f4ab 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java
@@ -67,7 +67,10 @@ import org.apache.hc.core5.util.Args;
* </p>
*
* @since 4.3
+ *
+ * @deprecated Use {@link org.apache.hc.core5.http.io.support.ClassicRequestBuilder}
*/
+@Deprecated
public class RequestBuilder {
private String method;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java
index fcb4883..2591aa9 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java
@@ -38,12 +38,12 @@ import java.util.Set;
import javax.net.ssl.SSLException;
import org.apache.hc.client5.http.HttpRequestRetryHandler;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.concurrent.CancellableDependency;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
@@ -163,7 +163,7 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
* @since 4.2
*/
protected boolean handleAsIdempotent(final HttpRequest request) {
- return StandardMethods.isIdempotent(request.getMethod());
+ return Methods.isIdempotent(request.getMethod());
}
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
index fac2d00..404e3de 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
@@ -34,7 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hc.client5.http.AuthenticationStrategy;
import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.async.AsyncExecCallback;
import org.apache.hc.client5.http.async.AsyncExecChain;
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
@@ -58,6 +57,7 @@ import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
@@ -180,7 +180,7 @@ public final class AsyncProtocolExec implements AsyncExecChainHandler {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
httpProcessor.process(response, entityDetails, clientContext);
- if (request.getMethod().equalsIgnoreCase(StandardMethods.TRACE.name())) {
+ if (Methods.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request
return asyncExecCallback.handleResponse(response, entityDetails);
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
index 225f362..2cc0715 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
@@ -32,7 +32,6 @@ import java.net.URI;
import org.apache.hc.client5.http.CircularRedirectException;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.RedirectException;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.async.AsyncExecCallback;
import org.apache.hc.client5.http.async.AsyncExecChain;
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
@@ -52,6 +51,7 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
@@ -141,8 +141,8 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
- if (!StandardMethods.isSafe(request.getMethod())) {
- final HttpRequest httpGet = new BasicHttpRequest(StandardMethods.GET.name(), redirectUri);
+ if (!Methods.isSafe(request.getMethod())) {
+ final HttpRequest httpGet = new BasicHttpRequest(Methods.GET, redirectUri);
httpGet.setHeaders(scope.originalRequest.getHeaders());
state.currentRequest = httpGet;
state.currentEntityProducer = null;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java
index 0f351f3..fc36f46 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java
@@ -34,7 +34,6 @@ import java.util.Iterator;
import org.apache.hc.client5.http.AuthenticationStrategy;
import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.auth.AuthExchange;
import org.apache.hc.client5.http.auth.ChallengeType;
import org.apache.hc.client5.http.auth.CredentialsProvider;
@@ -58,6 +57,7 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
@@ -166,7 +166,7 @@ public final class ProtocolExec implements ExecChainHandler {
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
httpProcessor.process(response, response.getEntity(), context);
- if (request.getMethod().equalsIgnoreCase(StandardMethods.TRACE.name())) {
+ if (Methods.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request
return response;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
index f6fa97f..c09a2ae 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
@@ -33,12 +33,10 @@ import java.net.URI;
import org.apache.hc.client5.http.CircularRedirectException;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.RedirectException;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.auth.AuthExchange;
import org.apache.hc.client5.http.classic.ExecChain;
import org.apache.hc.client5.http.classic.ExecChainHandler;
import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.classic.methods.RequestBuilder;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.protocol.RedirectLocations;
@@ -54,8 +52,10 @@ import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.LangUtils;
import org.slf4j.Logger;
@@ -143,7 +143,7 @@ public final class RedirectExec implements ExecChainHandler {
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
- if (!StandardMethods.isSafe(request.getMethod())) {
+ if (!Methods.isSafe(request.getMethod())) {
final HttpGet httpGet = new HttpGet(redirectUri);
httpGet.setHeaders(originalRequest.getHeaders());
redirect = httpGet;
@@ -152,7 +152,8 @@ public final class RedirectExec implements ExecChainHandler {
}
}
if (redirect == null) {
- redirect = RequestBuilder.copy(originalRequest).setUri(redirectUri).build();
+ redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);
+ redirect.setEntity(originalRequest.getEntity());
}
final HttpHost newTarget = URIUtils.extractHost(redirectUri);
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java
index d7768d7..babe670 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java
@@ -33,6 +33,7 @@ import javax.net.ssl.SSLEngine;
import org.apache.hc.core5.function.Factory;
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
+import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
import org.apache.hc.core5.reactor.ssl.TlsDetails;
import org.apache.hc.core5.ssl.SSLContexts;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java
index 8af69fb..2310c30 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java
@@ -30,6 +30,7 @@ package org.apache.hc.client5.http.ssl;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
+import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContexts;
/**
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TLS.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TLS.java
index a369d6f..5d175ea 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TLS.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TLS.java
@@ -29,13 +29,15 @@ package org.apache.hc.client5.http.ssl;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.message.ParserCursor;
/**
* Supported {@code TLS} protocol versions.
*
* @since 5.0
+ *
+ * @deprecated Use {@link org.apache.hc.core5.http.ssl.TLS}
*/
+@Deprecated
public enum TLS {
V_1_0("TLSv1", new ProtocolVersion("TLS", 1, 0)),
@@ -68,11 +70,7 @@ public enum TLS {
}
public static ProtocolVersion parse(final String s) throws ParseException {
- if (s == null) {
- return null;
- }
- final ParserCursor cursor = new ParserCursor(0, s.length());
- return TlsVersionParser.INSTANCE.parse(s, cursor, null);
+ return org.apache.hc.core5.http.ssl.TLS.parse(s);
}
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
index 1901909..6c3cf54 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
@@ -41,6 +41,7 @@ import javax.security.auth.x500.X500Principal;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.ssl.TLS;
import org.slf4j.Logger;
final class TlsSessionValidator {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsVersionParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsVersionParser.java
deleted file mode 100644
index 606bdea..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsVersionParser.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.ssl;
-
-import java.util.BitSet;
-
-import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.message.ParserCursor;
-import org.apache.hc.core5.http.message.TokenParser;
-
-final class TlsVersionParser {
-
- public final static TlsVersionParser INSTANCE = new TlsVersionParser();
-
- private final TokenParser tokenParser;
-
- TlsVersionParser() {
- this.tokenParser = TokenParser.INSTANCE;
- }
-
- ProtocolVersion parse(
- final CharSequence buffer,
- final ParserCursor cursor,
- final BitSet delimiters) throws ParseException {
- final int lowerBound = cursor.getLowerBound();
- final int upperBound = cursor.getUpperBound();
-
- int pos = cursor.getPos();
- if (pos + 4 > cursor.getUpperBound()) {
- throw new ParseException("Invalid TLS protocol version", buffer, lowerBound, upperBound, pos);
- }
- if (buffer.charAt(pos) != 'T' || buffer.charAt(pos + 1) != 'L' || buffer.charAt(pos + 2) != 'S'
- || buffer.charAt(pos + 3) != 'v') {
- throw new ParseException("Invalid TLS protocol version", buffer, lowerBound, upperBound, pos);
- }
- pos = pos + 4;
- cursor.updatePos(pos);
- if (cursor.atEnd()) {
- throw new ParseException("Invalid TLS version", buffer, lowerBound, upperBound, pos);
- }
- final String s = this.tokenParser.parseToken(buffer, cursor, delimiters);
- final int idx = s.indexOf('.');
- if (idx == -1) {
- final int major;
- try {
- major = Integer.parseInt(s);
- } catch (final NumberFormatException e) {
- throw new ParseException("Invalid TLS major version", buffer, lowerBound, upperBound, pos);
- }
- return new ProtocolVersion("TLS", major, 0);
- } else {
- final String s1 = s.substring(0, idx);
- final int major;
- try {
- major = Integer.parseInt(s1);
- } catch (final NumberFormatException e) {
- throw new ParseException("Invalid TLS major version", buffer, lowerBound, upperBound, pos);
- }
- final String s2 = s.substring(idx + 1);
- final int minor;
- try {
- minor = Integer.parseInt(s2);
- } catch (final NumberFormatException e) {
- throw new ParseException("Invalid TLS minor version", buffer, lowerBound, upperBound, pos);
- }
- return new ProtocolVersion("TLS", major, minor);
- }
- }
-
- ProtocolVersion parse(final String s) throws ParseException {
- if (s == null) {
- return null;
- }
- final ParserCursor cursor = new ParserCursor(0, s.length());
- return parse(s, cursor, null);
- }
-
-}
-
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestAsyncRequestBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestAsyncRequestBuilder.java
deleted file mode 100644
index cb1e5e9..0000000
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestAsyncRequestBuilder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.async.methods;
-
-import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
-import org.junit.Test;
-
-public class TestAsyncRequestBuilder {
-
- @Test(expected = IllegalStateException.class)
- public void testBuildTraceWithEntity() {
- final AsyncRequestBuilder builder = AsyncRequestBuilder.create("TRACE").setUri("/path");
- builder.setEntity(new BasicAsyncEntityProducer("stuff"));
- builder.build();
- }
-
-}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestRequestBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestRequestBuilder.java
deleted file mode 100644
index b6789c2..0000000
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestRequestBuilder.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.classic.methods;
-
-import java.net.URI;
-import java.net.URLEncoder;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-import org.apache.hc.client5.http.config.Configurable;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ContentType;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.io.entity.StringEntity;
-import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestRequestBuilder {
-
- @Test
- public void testBasicGet() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.get().build();
- Assert.assertNotNull(request);
- Assert.assertEquals("GET", request.getMethod());
- Assert.assertEquals(URI.create("/"), request.getUri());
- }
-
- @Test
- public void testArbitraryMethod() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.create("Whatever").build();
- Assert.assertNotNull(request);
- Assert.assertEquals("Whatever", request.getMethod());
- Assert.assertEquals(URI.create("/"), request.getUri());
- }
-
- @Test
- public void testBasicWithEntity() throws Exception {
- final HttpEntity entity = new StringEntity("whatever");
- final ClassicHttpRequest request = RequestBuilder.post().setEntity(entity).build();
- Assert.assertNotNull(request);
- Assert.assertEquals("POST", request.getMethod());
- Assert.assertEquals(URI.create("/"), request.getUri());
- Assert.assertSame(entity, request.getEntity());
- }
-
- @Test
- public void testGetWithEntity() throws Exception {
- final HttpEntity entity = new StringEntity("whatever");
- final ClassicHttpRequest request = RequestBuilder.get().setEntity(entity).build();
- Assert.assertNotNull(request);
- Assert.assertEquals("GET", request.getMethod());
- Assert.assertEquals(URI.create("/"), request.getUri());
- Assert.assertSame(entity, request.getEntity());
- }
-
- @Test
- public void testAddParameters1() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.get()
- .addParameter("p1", "this")
- .addParameter("p2", "that")
- .build();
- Assert.assertEquals(new URI("/?p1=this&p2=that"), request.getUri());
- }
-
- @Test
- public void testAddParameters2() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.get()
- .addParameter("p1", "this")
- .addParameters(new BasicNameValuePair("p2", "that"))
- .build();
- Assert.assertEquals(new URI("/?p1=this&p2=that"), request.getUri());
- }
-
- @Test
- public void testAddParameters3() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.post()
- .addParameter("p1", "this")
- .addParameter("p2", "that")
- .build();
- final HttpEntity entity = request.getEntity();
- Assert.assertNotNull(entity);
- Assert.assertEquals(new URI("/"), request.getUri());
- Assert.assertEquals("p1=this&p2=that", EntityUtils.toString(entity));
- }
-
- @Test
- public void testAddParameters4() throws Exception {
- final ClassicHttpRequest request = RequestBuilder.post()
- .setUri("http://targethost/?blah")
- .addParameter("p1", "this")
- .addParameter("p2", "that")
- .setEntity(new StringEntity("blah"))
- .build();
- Assert.assertEquals(new URI("http://targethost/?blah&p1=this&p2=that"), request.getUri());
- }
-
- @Test
- public void testCopy() throws Exception {
- final HttpEntity entity = new StringEntity("stuff");
- final RequestConfig config = RequestConfig.custom().build();
- final ClassicHttpRequest request = RequestBuilder.put()
- .setUri(URI.create("/stuff"))
- .setVersion(HttpVersion.HTTP_1_0)
- .addHeader("header1", "stuff")
- .setHeader("header2", "more stuff")
- .setEntity(entity)
- .setConfig(config)
- .build();
- Assert.assertNotNull(request);
- Assert.assertEquals("PUT", request.getMethod());
- Assert.assertEquals(URI.create("/stuff"), request.getUri());
- Assert.assertEquals(HttpVersion.HTTP_1_0, request.getVersion());
-
- final ClassicHttpRequest copy = RequestBuilder.copy(request).setUri("/other-stuff").build();
- Assert.assertEquals("PUT", copy.getMethod());
- Assert.assertEquals(URI.create("/other-stuff"), copy.getUri());
- Assert.assertSame(entity, copy.getEntity());
- Assert.assertTrue(copy instanceof Configurable);
- Assert.assertSame(config, ((Configurable) copy).getConfig());
- }
-
- @Test
- public void testCopyWithQueryParams() throws Exception {
- final HttpGet get = new HttpGet("/stuff?p1=this&p2=that");
- final RequestBuilder builder = RequestBuilder.copy(get).setEntity(new StringEntity(""));
- final List<NameValuePair> parameters = builder.getParameters();
- Assert.assertNotNull(parameters);
- Assert.assertEquals(0, parameters.size());
- Assert.assertEquals(new URI("/stuff?p1=this&p2=that"), builder.getUri());
- }
-
- @Test
- public void testCopyWithFormParams() throws Exception {
- final HttpPost post = new HttpPost("/stuff?p1=wtf");
- post.setEntity(new StringEntity("p1=this&p2=that", ContentType.APPLICATION_FORM_URLENCODED));
- final RequestBuilder builder = RequestBuilder.copy(post);
- final List<NameValuePair> parameters = builder.getParameters();
- Assert.assertNotNull(parameters);
- Assert.assertEquals(2, parameters.size());
- assertNameValuePair(new BasicNameValuePair("p1", "this"), parameters.get(0));
- assertNameValuePair(new BasicNameValuePair("p2", "that"), parameters.get(1));
- Assert.assertEquals(new URI("/stuff?p1=wtf"), builder.getUri());
- Assert.assertNull(builder.getEntity());
- }
-
- private static void assertNameValuePair (
- final NameValuePair expected,
- final NameValuePair result) {
- Assert.assertNotNull(result);
- Assert.assertEquals(expected.getName(), result.getName());
- Assert.assertEquals(expected.getValue(), result.getValue());
- }
-
- @Test
- public void testCopyWithStringEntity() throws Exception {
- final HttpPost post = new HttpPost("/stuff?p1=wtf");
- final HttpEntity entity = new StringEntity("p1=this&p2=that", ContentType.TEXT_PLAIN);
- post.setEntity(entity);
- final RequestBuilder builder = RequestBuilder.copy(post);
- final List<NameValuePair> parameters = builder.getParameters();
- Assert.assertNotNull(parameters);
- Assert.assertEquals(0, parameters.size());
- Assert.assertEquals(new URI("/stuff?p1=wtf"), builder.getUri());
- Assert.assertSame(entity, builder.getEntity());
- }
-
- @Test
- public void testCopyAndSetUri() throws Exception {
- final URI uri1 = URI.create("http://host1.com/path?param=something");
- final URI uri2 = URI.create("http://host2.com/path?param=somethingdifferent");
- final HttpGet request1 = new HttpGet(uri1);
- final ClassicHttpRequest request2 = RequestBuilder.copy(request1).setUri(uri2).build();
- Assert.assertEquals(request2.getUri(), uri2);
- }
-
- @Test
- public void testGettersAndMutators() throws Exception {
- final HttpEntity entity = new StringEntity("stuff");
- final RequestConfig config = RequestConfig.custom().build();
- final Header h1 = new BasicHeader("header1", "stuff");
- final Header h2 = new BasicHeader("header1", "more-stuff");
- final RequestBuilder builder = RequestBuilder.put()
- .setUri("/stuff")
- .setVersion(HttpVersion.HTTP_1_0)
- .addHeader(h1)
- .addHeader(h2)
- .setEntity(entity)
- .setConfig(config);
- Assert.assertEquals("PUT", builder.getMethod());
- Assert.assertEquals(URI.create("/stuff"), builder.getUri());
- Assert.assertEquals(HttpVersion.HTTP_1_0, builder.getVersion());
- Assert.assertSame(h1, builder.getFirstHeader("header1"));
- Assert.assertSame(h2, builder.getLastHeader("header1"));
- Assert.assertEquals(2, builder.getHeaders("header1").length);
- Assert.assertSame(entity, builder.getEntity());
- Assert.assertSame(config, builder.getConfig());
-
- builder.setUri((String) null)
- .setVersion(null)
- .removeHeader(h1)
- .removeHeaders("header1")
- .removeHeader(h2)
- .setEntity(null)
- .setConfig(null);
- Assert.assertEquals(null, builder.getUri());
- Assert.assertEquals(null, builder.getVersion());
- Assert.assertSame(null, builder.getFirstHeader("header1"));
- Assert.assertSame(null, builder.getLastHeader("header1"));
- Assert.assertEquals(0, builder.getHeaders("header1").length);
- Assert.assertSame(null, builder.getEntity());
- Assert.assertSame(null, builder.getConfig());
-
- builder.setHeader(h2)
- .setHeader("header1", "a-lot-more-stuff");
- Assert.assertSame("a-lot-more-stuff", builder.getLastHeader("header1").getValue());
- Assert.assertEquals(1, builder.getHeaders("header1").length);
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testCopyNull() throws Exception {
- RequestBuilder.copy(null);
- }
-
- @Test
- public void testBuildGETwithUTF8() throws Exception {
- assertBuild(StandardCharsets.UTF_8);
- }
-
- @Test
- public void testBuildGETwithISO88591() throws Exception {
- assertBuild(StandardCharsets.ISO_8859_1);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testBuildTraceWithEntity() {
- final RequestBuilder requestBuilder = RequestBuilder.create("TRACE").setUri("/path");
- requestBuilder.setEntity(new StringEntity("foo"));
- requestBuilder.build();
- }
-
- private void assertBuild(final Charset charset) throws Exception {
- final RequestBuilder requestBuilder = RequestBuilder.create("GET").setCharset(charset);
- requestBuilder.setUri("https://somehost.com/stuff");
- requestBuilder.addParameters(createParameters());
-
- final String encodedData1 = URLEncoder.encode("\"1\u00aa position\"", charset.displayName());
- final String encodedData2 = URLEncoder.encode("Jos\u00e9 Abra\u00e3o", charset.displayName());
-
- final String uriExpected = String.format("https://somehost.com/stuff?parameter1=value1¶meter2=%s¶meter3=%s", encodedData1, encodedData2);
-
- final ClassicHttpRequest request = requestBuilder.build();
- Assert.assertEquals(uriExpected, request.getUri().toString());
- }
-
- private NameValuePair[] createParameters() {
- final NameValuePair parameters[] = new NameValuePair[3];
- parameters[0] = new BasicNameValuePair("parameter1", "value1");
- parameters[1] = new BasicNameValuePair("parameter2", "\"1\u00aa position\"");
- parameters[2] = new BasicNameValuePair("parameter3", "Jos\u00e9 Abra\u00e3o");
- return parameters;
- }
-
-}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
index 12fcd53..22dc283 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
@@ -33,7 +33,6 @@ import java.util.concurrent.Future;
import org.apache.hc.client5.http.async.methods.AbstractBinPushConsumer;
import org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.function.Supplier;
@@ -42,8 +41,10 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
+import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.io.CloseMode;
@@ -117,7 +118,7 @@ public class AsyncClientHttp2ServerPush {
final HttpHost target = new HttpHost("nghttp2.org");
final String requestURI = "/httpbin/";
final Future<Void> future = client.execute(
- AsyncRequestBuilder.get(target, requestURI).build(),
+ new BasicRequestProducer(Methods.GET, target, requestURI),
new AbstractCharResponseConsumer<Void>() {
@Override
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
index 92673e3..c7c884f 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
@@ -31,14 +31,15 @@ import java.nio.CharBuffer;
import java.util.concurrent.Future;
import org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.message.StatusLine;
+import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.util.Timeout;
@@ -65,7 +66,7 @@ public class AsyncClientHttpExchangeStreaming {
for (final String requestUri: requestUris) {
final Future<Void> future = client.execute(
- AsyncRequestBuilder.get(target, requestUri).build(),
+ new BasicRequestProducer(Methods.GET, target, requestUri),
new AbstractCharResponseConsumer<Void>() {
@Override
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
index 0563bbe..db2b916 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
@@ -33,7 +33,6 @@ import java.util.concurrent.Future;
import org.apache.hc.client5.http.async.AsyncExecCallback;
import org.apache.hc.client5.http.async.AsyncExecChain;
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
import org.apache.hc.client5.http.impl.ChainElements;
@@ -47,6 +46,7 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer;
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
import org.apache.hc.core5.http.nio.entity.DigestingEntityProducer;
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
+import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.util.Timeout;
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
index b3dcc58..f6b4c89 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
@@ -34,7 +34,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer;
-import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequests;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
@@ -45,6 +44,7 @@ import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
+import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
public class AsyncQuickStart {
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java
index 73a4d8c..ef4b173 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java
@@ -41,8 +41,8 @@ import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
-import org.apache.hc.client5.http.ssl.TLS;
import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.ssl.TrustStrategy;
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
index 4d0989d..0b2d97d 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
@@ -30,7 +30,6 @@ import java.net.URI;
import java.util.List;
import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.classic.methods.RequestBuilder;
import org.apache.hc.client5.http.cookie.BasicCookieStore;
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
@@ -39,6 +38,7 @@ import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
/**
* A example that demonstrates how HttpClient APIs can be used to perform
@@ -69,7 +69,7 @@ public class ClientFormLogin {
}
}
- final ClassicHttpRequest login = RequestBuilder.post()
+ final ClassicHttpRequest login = ClassicRequestBuilder.post()
.setUri(new URI("https://someportal/"))
.addParameter("IDToken1", "username")
.addParameter("IDToken2", "password")
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
index ab3294d..fa2ff2b 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
@@ -27,7 +27,6 @@
package org.apache.hc.client5.http.impl.classic;
import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.StandardMethods;
import org.apache.hc.client5.http.classic.ExecChain;
import org.apache.hc.client5.http.classic.ExecRuntime;
import org.apache.hc.client5.http.config.RequestConfig;
@@ -40,6 +39,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.Methods;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
@@ -77,7 +77,7 @@ public class TestContentCompressionExec {
@Test
public void testContentEncodingNoEntity() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
Mockito.when(execChain.proceed(request, scope)).thenReturn(response);
@@ -90,7 +90,7 @@ public class TestContentCompressionExec {
@Test
public void testNoContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final StringEntity original = new StringEntity("plain stuff");
response.setEntity(original);
@@ -106,7 +106,7 @@ public class TestContentCompressionExec {
@Test
public void testGzipContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original);
@@ -122,7 +122,7 @@ public class TestContentCompressionExec {
@Test
public void testGzipContentEncodingZeroLength() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build();
response.setEntity(original);
@@ -138,7 +138,7 @@ public class TestContentCompressionExec {
@Test
public void testXGzipContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build();
response.setEntity(original);
@@ -154,7 +154,7 @@ public class TestContentCompressionExec {
@Test
public void testDeflateContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build();
response.setEntity(original);
@@ -170,7 +170,7 @@ public class TestContentCompressionExec {
@Test
public void testIdentityContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build();
response.setEntity(original);
@@ -186,7 +186,7 @@ public class TestContentCompressionExec {
@Test(expected=HttpException.class)
public void testUnknownContentEncoding() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build();
response.setEntity(original);
@@ -200,7 +200,7 @@ public class TestContentCompressionExec {
@Test
public void testContentEncodingRequestParameter() throws Exception {
- final ClassicHttpRequest request = new BasicClassicHttpRequest(StandardMethods.GET.name(), host, "/");
+ final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestTlsVersionParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestTlsVersionParser.java
deleted file mode 100644
index 30654b6..0000000
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestTlsVersionParser.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.ssl;
-
-import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.message.ParserCursor;
-import org.apache.hc.core5.http.message.TokenParser;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link TlsVersionParser}.
- */
-public class TestTlsVersionParser {
-
- private TlsVersionParser impl;
-
- @Before
- public void setup() {
- impl = new TlsVersionParser();
- }
-
- @Test
- public void testParseBasic() throws Exception {
- Assert.assertThat(impl.parse("TLSv1"), CoreMatchers.equalTo(TLS.V_1_0.version));
- Assert.assertThat(impl.parse("TLSv1.1"), CoreMatchers.equalTo(TLS.V_1_1.version));
- Assert.assertThat(impl.parse("TLSv1.2"), CoreMatchers.equalTo(TLS.V_1_2.version));
- Assert.assertThat(impl.parse("TLSv1.3"), CoreMatchers.equalTo(TLS.V_1_3.version));
- Assert.assertThat(impl.parse("TLSv22.356"), CoreMatchers.equalTo(new ProtocolVersion("TLS", 22, 356)));
- }
-
- @Test
- public void testParseBuffer() throws Exception {
- final ParserCursor cursor = new ParserCursor(1, 13);
- Assert.assertThat(impl.parse(" TLSv1.2,0000", cursor, TokenParser.INIT_BITSET(',')),
- CoreMatchers.equalTo(TLS.V_1_2.version));
- Assert.assertThat(cursor.getPos(), CoreMatchers.equalTo(8));
- }
-
- @Test(expected = ParseException.class)
- public void testParseFailure1() throws Exception {
- impl.parse("Tlsv1");
- }
-
- @Test(expected = ParseException.class)
- public void testParseFailure2() throws Exception {
- impl.parse("TLSV1");
- }
-
- @Test(expected = ParseException.class)
- public void testParseFailure3() throws Exception {
- impl.parse("TLSv");
- }
-
- @Test(expected = ParseException.class)
- public void testParseFailure4() throws Exception {
- impl.parse("TLSv1A");
- }
-
- @Test(expected = ParseException.class)
- public void testParseFailure5() throws Exception {
- impl.parse("TLSv1.A");
- }
-
-}