mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
HTTPCLIENT-1931, HTTPCLIENT-1932: Changed ClassicHttpRequests factory methods to return HttpUriRequestBase; added SimpleHttpRequests factory enum
This commit is contained in:
parent
92ee24efb8
commit
fa4a4d3bd6
@ -34,6 +34,7 @@
|
||||
|
||||
import org.apache.hc.client5.http.AuthenticationStrategy;
|
||||
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;
|
||||
import org.apache.hc.client5.http.auth.AuthChallenge;
|
||||
import org.apache.hc.client5.http.auth.AuthScheme;
|
||||
@ -162,7 +163,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -189,7 +190,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -216,7 +217,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -243,7 +244,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequest.put(target, "/");
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.PUT.create(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
@ -273,7 +274,7 @@ public AsyncServerExchangeHandler get() {
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequest.put(target, "/");
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.PUT.create(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
@ -300,7 +301,7 @@ public AsyncServerExchangeHandler get() {
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequest.put(target, "/");
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.PUT.create(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
@ -343,12 +344,12 @@ public List<AuthScheme> select(
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response1 = future1.get();
|
||||
Assert.assertNotNull(response1);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response1.getCode());
|
||||
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response2 = future2.get();
|
||||
Assert.assertNotNull(response2);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
|
||||
@ -370,7 +371,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target.getSchemeName() + "://test:test@" + target.toHostString() + "/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target.getSchemeName() + "://test:test@" + target.toHostString() + "/"), context, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -391,7 +392,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target.getSchemeName() + "://test:all-worng@" + target.toHostString() + "/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target.getSchemeName() + "://test:all-worng@" + target.toHostString() + "/"), context, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -429,7 +430,7 @@ protected SimpleHttpResponse handle(
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target.getSchemeName() + "://test:test@" + target.toHostString() + "/thatway"), context, null);
|
||||
SimpleHttpRequests.GET.create(target.getSchemeName() + "://test:test@" + target.toHostString() + "/thatway"), context, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
@ -512,7 +513,7 @@ protected void customizeUnauthorizedResponse(final HttpResponse unauthorized) {
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/");
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, "/");
|
||||
request.setConfig(config);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(request, context, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
@ -553,7 +554,7 @@ protected void customizeUnauthorizedResponse(final HttpResponse unauthorized) {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
|
||||
|
@ -37,7 +37,7 @@
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
@ -64,7 +64,7 @@ public void testSequenctialGetRequests() throws Exception {
|
||||
final HttpHost target = start();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/random/2048"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/random/2048"), null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
Assert.assertThat(response, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
|
||||
@ -79,7 +79,7 @@ public void testSequenctialHeadRequests() throws Exception {
|
||||
final HttpHost target = start();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.head(target, "/random/2048"), null);
|
||||
SimpleHttpRequests.HEAD.create(target, "/random/2048"), null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
Assert.assertThat(response, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
|
||||
@ -154,7 +154,7 @@ public void completed(final SimpleHttpResponse result) {
|
||||
try {
|
||||
resultQueue.add(result);
|
||||
if (count.decrementAndGet() > 0) {
|
||||
httpclient.execute(SimpleHttpRequest.get(target, "/random/2048"), this);
|
||||
httpclient.execute(SimpleHttpRequests.GET.create(target, "/random/2048"), this);
|
||||
}
|
||||
} finally {
|
||||
countDownLatch.countDown();
|
||||
@ -180,7 +180,7 @@ public void cancelled() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Thread.currentThread().isInterrupted()) {
|
||||
httpclient.execute(SimpleHttpRequest.get(target, "/random/2048"), callback);
|
||||
httpclient.execute(SimpleHttpRequests.GET.create(target, "/random/2048"), callback);
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public void run() {
|
||||
public void testBadRequest() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/random/boom"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/random/boom"), null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
Assert.assertThat(response, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response.getCode(), CoreMatchers.equalTo(400));
|
||||
|
@ -37,6 +37,7 @@
|
||||
import org.apache.hc.client5.http.CircularRedirectException;
|
||||
import org.apache.hc.client5.http.RedirectException;
|
||||
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;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||
@ -201,7 +202,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -225,7 +226,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -249,7 +250,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -281,7 +282,7 @@ protected SimpleHttpResponse handle(
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -304,7 +305,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -328,7 +329,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -351,7 +352,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -374,7 +375,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -401,7 +402,7 @@ public AsyncServerExchangeHandler get() {
|
||||
.setCircularRedirectsAllowed(true)
|
||||
.setMaxRedirects(5).build();
|
||||
try {
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/circular-oldlocation/");
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, "/circular-oldlocation/");
|
||||
request.setConfig(config);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(request, null);
|
||||
future.get();
|
||||
@ -427,7 +428,7 @@ public AsyncServerExchangeHandler get() {
|
||||
.setCircularRedirectsAllowed(false)
|
||||
.build();
|
||||
try {
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/circular-oldlocation/");
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, "/circular-oldlocation/");
|
||||
request.setConfig(config);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(request, null);
|
||||
future.get();
|
||||
@ -451,7 +452,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final SimpleHttpRequest post = SimpleHttpRequest.post(target, "/oldlocation/");
|
||||
final SimpleHttpRequest post = SimpleHttpRequests.POST.create(target, "/oldlocation/");
|
||||
post.setBodyText("stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(post, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
@ -479,7 +480,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -505,7 +506,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/test/oldlocation"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/test/oldlocation"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -563,7 +564,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
try {
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), null);
|
||||
future.get();
|
||||
} catch (final ExecutionException ex) {
|
||||
Assert.assertTrue(ex.getCause() instanceof HttpException);
|
||||
@ -585,7 +586,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
try {
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), null);
|
||||
future.get();
|
||||
} catch (final ExecutionException e) {
|
||||
Assert.assertTrue(e.getCause() instanceof ProtocolException);
|
||||
@ -616,7 +617,7 @@ public AsyncServerExchangeHandler get() {
|
||||
cookieStore.addCookie(cookie);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -691,7 +692,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final Queue<Future<SimpleHttpResponse>> queue = new ConcurrentLinkedQueue<>();
|
||||
for (int i = 0; i < 1; i++) {
|
||||
queue.add(httpclient.execute(SimpleHttpRequest.get(initialTarget, "/redirect/anywhere"), null));
|
||||
queue.add(httpclient.execute(SimpleHttpRequests.GET.create(initialTarget, "/redirect/anywhere"), null));
|
||||
}
|
||||
while (!queue.isEmpty()) {
|
||||
final Future<SimpleHttpResponse> future = queue.remove();
|
||||
@ -743,12 +744,12 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/rome"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/rome"), context, null);
|
||||
final HttpResponse response1 = future1.get();
|
||||
Assert.assertNotNull(response1);
|
||||
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/rome"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/rome"), context, null);
|
||||
final HttpResponse response2 = future2.get();
|
||||
Assert.assertNotNull(response2);
|
||||
|
||||
@ -774,12 +775,12 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/lille"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/lille"), context, null);
|
||||
final HttpResponse response1 = future1.get();
|
||||
Assert.assertNotNull(response1);
|
||||
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/lille"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/lille"), context, null);
|
||||
final HttpResponse response2 = future2.get();
|
||||
Assert.assertNotNull(response2);
|
||||
|
||||
@ -805,12 +806,12 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/alian"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/alian"), context, null);
|
||||
final HttpResponse response1 = future1.get();
|
||||
Assert.assertNotNull(response1);
|
||||
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/lille"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/lille"), context, null);
|
||||
final HttpResponse response2 = future2.get();
|
||||
Assert.assertNotNull(response2);
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
@ -120,7 +121,7 @@ public HttpHost start() throws Exception {
|
||||
public void testSequenctialGetRequestsCloseConnection() throws Exception {
|
||||
final HttpHost target = start();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final SimpleHttpRequest get = SimpleHttpRequest.get(target, "/random/2048");
|
||||
final SimpleHttpRequest get = SimpleHttpRequests.GET.create(target, "/random/2048");
|
||||
get.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(get, null);
|
||||
final SimpleHttpResponse response = future.get();
|
||||
@ -150,7 +151,7 @@ public void testConcurrentPostsOverSingleConnection() throws Exception {
|
||||
public void testSharedPool() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/random/2048"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/random/2048"), null);
|
||||
final SimpleHttpResponse response1 = future1.get();
|
||||
Assert.assertThat(response1, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(200));
|
||||
@ -165,7 +166,7 @@ public void testSharedPool() throws Exception {
|
||||
.build()) {
|
||||
httpclient2.start();
|
||||
final Future<SimpleHttpResponse> future2 = httpclient2.execute(
|
||||
SimpleHttpRequest.get(target, "/random/2048"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/random/2048"), null);
|
||||
final SimpleHttpResponse response2 = future2.get();
|
||||
Assert.assertThat(response2, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(200));
|
||||
@ -175,7 +176,7 @@ public void testSharedPool() throws Exception {
|
||||
}
|
||||
|
||||
final Future<SimpleHttpResponse> future3 = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/random/2048"), null);
|
||||
SimpleHttpRequests.GET.create(target, "/random/2048"), null);
|
||||
final SimpleHttpResponse response3 = future3.get();
|
||||
Assert.assertThat(response3, CoreMatchers.notNullValue());
|
||||
Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(200));
|
||||
|
@ -35,6 +35,7 @@
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
@ -182,7 +183,7 @@ public AsyncServerExchangeHandler get() {
|
||||
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -206,7 +207,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpHost target = start();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
@ -237,7 +238,7 @@ public AsyncServerExchangeHandler get() {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
SimpleHttpRequest.get(target, "/oldlocation/"), context, null);
|
||||
SimpleHttpRequests.GET.create(target, "/oldlocation/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.UserTokenHandler;
|
||||
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;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
@ -215,7 +216,7 @@ public void run() {
|
||||
try {
|
||||
context.setAttribute("user", uid);
|
||||
for (int r = 0; r < requestCount; r++) {
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequest.get(target, "/");
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(target, "/");
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(httpget, null);
|
||||
future.get();
|
||||
|
||||
@ -276,7 +277,7 @@ public Object getUserToken(final HttpRoute route, final HttpContext context) {
|
||||
final HttpContext context1 = new BasicHttpContext();
|
||||
context1.setAttribute("user", "stuff");
|
||||
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(SimpleHttpRequest.get(target, "/"), context1, null);
|
||||
final Future<SimpleHttpResponse> future1 = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context1, null);
|
||||
final HttpResponse response1 = future1.get();
|
||||
Assert.assertNotNull(response1);
|
||||
Assert.assertEquals(200, response1.getCode());
|
||||
@ -291,7 +292,7 @@ public Object getUserToken(final HttpRoute route, final HttpContext context) {
|
||||
// Send it to another route. Must be a keepalive.
|
||||
final HttpContext context2 = new BasicHttpContext();
|
||||
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(SimpleHttpRequest.get(
|
||||
final Future<SimpleHttpResponse> future2 = httpclient.execute(SimpleHttpRequests.GET.create(
|
||||
new HttpHost("127.0.0.1", target.getPort(), target.getSchemeName()),"/"), context2, null);
|
||||
final HttpResponse response2 = future2.get();
|
||||
Assert.assertNotNull(response2);
|
||||
@ -309,7 +310,7 @@ public Object getUserToken(final HttpRoute route, final HttpContext context) {
|
||||
// The killed conn is the oldest, which means the first HTTPGet ([localhost][stuff]).
|
||||
// When this happens, the RouteSpecificPool becomes empty.
|
||||
final HttpContext context3 = new BasicHttpContext();
|
||||
final Future<SimpleHttpResponse> future3 = httpclient.execute(SimpleHttpRequest.get(target, "/"), context3, null);
|
||||
final Future<SimpleHttpResponse> future3 = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context3, null);
|
||||
final HttpResponse response3 = future3.get();
|
||||
Assert.assertNotNull(response3);
|
||||
Assert.assertEquals(200, response3.getCode());
|
||||
|
@ -31,7 +31,7 @@
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.hc.client5.http.AuthenticationStrategy;
|
||||
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;
|
||||
import org.apache.hc.client5.http.auth.AuthSchemeProvider;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
@ -166,7 +166,7 @@ protected void customizeUnauthorizedResponse(final HttpResponse unauthorized) {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequest.get(target, "/"), context, null);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(SimpleHttpRequests.GET.create(target, "/"), context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
|
@ -38,6 +38,7 @@
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.cache.CacheResponseStatus;
|
||||
import org.apache.hc.client5.http.cache.HttpCacheContext;
|
||||
@ -130,7 +131,7 @@ void execute() throws Exception {
|
||||
// Initial ping
|
||||
{
|
||||
final HttpCacheContext context = HttpCacheContext.create();
|
||||
final SimpleHttpRequest options = SimpleHttpRequest.options(target, "*");
|
||||
final SimpleHttpRequest options = SimpleHttpRequests.OPTIONS.create(target, "*");
|
||||
final Future<SimpleHttpResponse> future = client.execute(options, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -154,7 +155,7 @@ void execute() throws Exception {
|
||||
|
||||
final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$");
|
||||
final List<String> links = new ArrayList<>();
|
||||
final SimpleHttpRequest getRoot1 = SimpleHttpRequest.get(target, "/");
|
||||
final SimpleHttpRequest getRoot1 = SimpleHttpRequests.GET.create(target, "/");
|
||||
final Future<SimpleHttpResponse> future1 = client.execute(getRoot1, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -178,7 +179,7 @@ void execute() throws Exception {
|
||||
logResult(TestResult.NOK, getRoot1, "(time out)");
|
||||
}
|
||||
for (final String link: links) {
|
||||
final SimpleHttpRequest getLink = SimpleHttpRequest.get(target, link);
|
||||
final SimpleHttpRequest getLink = SimpleHttpRequests.GET.create(target, link);
|
||||
final Future<SimpleHttpResponse> linkFuture = client.execute(getLink, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = linkFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -197,7 +198,7 @@ void execute() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
final SimpleHttpRequest getRoot2 = SimpleHttpRequest.get(target, "/");
|
||||
final SimpleHttpRequest getRoot2 = SimpleHttpRequests.GET.create(target, "/");
|
||||
final Future<SimpleHttpResponse> future2 = client.execute(getRoot2, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -215,7 +216,7 @@ void execute() throws Exception {
|
||||
logResult(TestResult.NOK, getRoot2, "(time out)");
|
||||
}
|
||||
for (final String link: links) {
|
||||
final SimpleHttpRequest getLink = SimpleHttpRequest.get(target, link);
|
||||
final SimpleHttpRequest getLink = SimpleHttpRequests.GET.create(target, link);
|
||||
final Future<SimpleHttpResponse> linkFuture = client.execute(getLink, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = linkFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
|
@ -34,6 +34,7 @@
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.Credentials;
|
||||
@ -167,7 +168,7 @@ void execute() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final SimpleHttpRequest options = SimpleHttpRequest.options(target, "*");
|
||||
final SimpleHttpRequest options = SimpleHttpRequests.OPTIONS.create(target, "*");
|
||||
final Future<SimpleHttpResponse> future = client.execute(options, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -192,7 +193,7 @@ void execute() throws Exception {
|
||||
|
||||
final String[] requestUris = new String[] {"/", "/news.html", "/status.html"};
|
||||
for (final String requestUri: requestUris) {
|
||||
final SimpleHttpRequest httpGet = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest httpGet = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
final Future<SimpleHttpResponse> future = client.execute(httpGet, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -219,7 +220,7 @@ void execute() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequest.get(target, "/private/big-secret.txt");
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequests.GET.create(target, "/private/big-secret.txt");
|
||||
final Future<SimpleHttpResponse> future = client.execute(httpGetSecret, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -245,7 +246,7 @@ void execute() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequest.get(target, "/private/big-secret.txt");
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequests.GET.create(target, "/private/big-secret.txt");
|
||||
final Future<SimpleHttpResponse> future = client.execute(httpGetSecret, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -271,7 +272,7 @@ void execute() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequest.get(target, "/private/big-secret.txt");
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequests.GET.create(target, "/private/big-secret.txt");
|
||||
final Future<SimpleHttpResponse> future = client.execute(httpGetSecret, context, null);
|
||||
try {
|
||||
final SimpleHttpResponse response = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
|
||||
@ -298,7 +299,7 @@ void execute() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequest.get(target, "/private/big-secret.txt");
|
||||
final SimpleHttpRequest httpGetSecret = SimpleHttpRequests.GET.create(target, "/private/big-secret.txt");
|
||||
httpGetSecret.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
|
||||
final Future<SimpleHttpResponse> future = client.execute(httpGetSecret, context, null);
|
||||
try {
|
||||
|
@ -29,6 +29,7 @@
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
|
||||
@ -55,7 +56,7 @@ public static void main(String[] args) throws Exception {
|
||||
httpclient.start();
|
||||
|
||||
final String requestUri = "http://httpbin.org/basic-auth/user/passwd";
|
||||
SimpleHttpRequest httpget = SimpleHttpRequest.get(requestUri);
|
||||
SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(requestUri);
|
||||
|
||||
System.out.println("Executing request " + requestUri);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(
|
||||
|
@ -30,6 +30,7 @@
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
|
||||
@ -64,7 +65,7 @@ public static void main(final String[] args) throws Exception {
|
||||
|
||||
final HttpHost target = new HttpHost("httpbin.org");
|
||||
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, "/");
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, "/");
|
||||
final Future<SimpleHttpResponse> future1 = client.execute(
|
||||
SimpleRequestProducer.create(request),
|
||||
SimpleResponseConsumer.create(),
|
||||
|
@ -34,6 +34,7 @@
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
|
||||
@ -96,7 +97,7 @@ public boolean isTrusted(
|
||||
final String requestUri = "/";
|
||||
final HttpClientContext clientContext = HttpClientContext.create();
|
||||
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
final Future<SimpleHttpResponse> future = client.execute(
|
||||
SimpleRequestProducer.create(request),
|
||||
SimpleResponseConsumer.create(),
|
||||
|
@ -31,6 +31,7 @@
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
|
||||
@ -69,7 +70,7 @@ public static void main(final String[] args) throws Exception {
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(requestUris.length);
|
||||
for (final String requestUri: requestUris) {
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
endpoint.execute(
|
||||
SimpleRequestProducer.create(request),
|
||||
SimpleResponseConsumer.create(),
|
||||
|
@ -31,6 +31,7 @@
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
|
||||
@ -70,7 +71,7 @@ public static void main(final String[] args) throws Exception {
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(requestUris.length);
|
||||
for (final String requestUri: requestUris) {
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
endpoint.execute(
|
||||
SimpleRequestProducer.create(request),
|
||||
SimpleResponseConsumer.create(),
|
||||
|
@ -29,6 +29,7 @@
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
|
||||
@ -59,7 +60,7 @@ public static void main(final String[] args) throws Exception {
|
||||
final String[] requestUris = new String[] {"/", "/ip", "/user-agent", "/headers"};
|
||||
|
||||
for (final String requestUri: requestUris) {
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
|
||||
final Future<SimpleHttpResponse> future = client.execute(
|
||||
httpget,
|
||||
|
@ -37,6 +37,7 @@
|
||||
import org.apache.hc.client5.http.async.AsyncExecChain;
|
||||
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
|
||||
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;
|
||||
import org.apache.hc.client5.http.impl.ChainElements;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
@ -122,7 +123,7 @@ public void execute(
|
||||
|
||||
final String requestUri = "http://httpbin.org/get";
|
||||
for (int i = 0; i < 20; i++) {
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequest.get(requestUri);
|
||||
final SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(requestUri);
|
||||
System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
|
||||
final Future<SimpleHttpResponse> future = client.execute(
|
||||
httpget,
|
||||
|
@ -31,6 +31,7 @@
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
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;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
|
||||
@ -80,7 +81,7 @@ public final static void main(final String[] args) throws Exception {
|
||||
final String requestUri = "/httpbin/";
|
||||
final HttpClientContext clientContext = HttpClientContext.create();
|
||||
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
|
||||
final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
|
||||
final Future<SimpleHttpResponse> future = client.execute(
|
||||
SimpleRequestProducer.create(request),
|
||||
SimpleResponseConsumer.create(),
|
||||
|
@ -36,6 +36,7 @@
|
||||
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;
|
||||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
||||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
|
||||
@ -54,7 +55,7 @@ public static void main(String[] args) throws Exception {
|
||||
httpclient.start();
|
||||
|
||||
// Execute request
|
||||
final SimpleHttpRequest request1 = SimpleHttpRequest.get("http://httpbin.org/get");
|
||||
final SimpleHttpRequest request1 = SimpleHttpRequests.GET.create("http://httpbin.org/get");
|
||||
Future<SimpleHttpResponse> future = httpclient.execute(request1, null);
|
||||
// and wait until response is received
|
||||
final SimpleHttpResponse response1 = future.get();
|
||||
@ -62,7 +63,7 @@ public static void main(String[] args) throws Exception {
|
||||
|
||||
// One most likely would want to use a callback for operation result
|
||||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
final SimpleHttpRequest request2 = SimpleHttpRequest.get("http://httpbin.org/get");
|
||||
final SimpleHttpRequest request2 = SimpleHttpRequests.GET.create("http://httpbin.org/get");
|
||||
httpclient.execute(request2, new FutureCallback<SimpleHttpResponse>() {
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,7 @@
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.hc.client5.http.StandardMethods;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.message.BasicHttpRequest;
|
||||
|
||||
/**
|
||||
@ -44,6 +45,11 @@ public enum HttpRequests {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.DELETE.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.DELETE.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
GET {
|
||||
@ -51,6 +57,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.GET.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.GET.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
HEAD {
|
||||
@ -58,6 +69,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.HEAD.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.HEAD.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
OPTIONS {
|
||||
@ -65,6 +81,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.OPTIONS.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.OPTIONS.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
PATCH {
|
||||
@ -72,6 +93,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.PATCH.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.PATCH.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
POST {
|
||||
@ -79,6 +105,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.POST.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.POST.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
PUT {
|
||||
@ -86,6 +117,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.PUT.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.PUT.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
TRACE {
|
||||
@ -93,6 +129,11 @@ public BasicHttpRequest create(final URI uri) {
|
||||
public BasicHttpRequest create(final URI uri) {
|
||||
return new BasicHttpRequest(StandardMethods.TRACE.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicHttpRequest create(final HttpHost host, final String path) {
|
||||
return new BasicHttpRequest(StandardMethods.TRACE.name(), host, path);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -113,4 +154,13 @@ public BasicHttpRequest create(final String uri) {
|
||||
*/
|
||||
public abstract BasicHttpRequest create(URI uri);
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link BasicHttpRequest}.
|
||||
*
|
||||
* @param host HTTP host.
|
||||
* @param path request path.
|
||||
* @return a new subclass of BasicHttpRequest
|
||||
*/
|
||||
public abstract BasicHttpRequest create(final HttpHost host, final String path);
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
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;
|
||||
@ -40,121 +39,8 @@
|
||||
|
||||
public final class SimpleHttpRequest extends ConfigurableHttpRequest {
|
||||
|
||||
private RequestConfig requestConfig;
|
||||
private SimpleBody body;
|
||||
|
||||
public static SimpleHttpRequest get(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.GET, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest get(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.GET, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest get(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.GET, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest post(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.POST, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest post(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.POST, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest post(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.POST, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest put(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.PUT, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest put(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.PUT, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest put(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.PUT, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest head(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.HEAD, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest head(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.HEAD, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest head(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.HEAD, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest delete(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.DELETE, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest delete(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.DELETE, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest delete(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.DELETE, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest trace(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.TRACE, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest trace(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.TRACE, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest trace(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.TRACE, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest options(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.OPTIONS, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest options(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.OPTIONS, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest options(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.OPTIONS, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest patch(final URI requestUri) {
|
||||
Args.notNull(requestUri, "Request URI");
|
||||
return new SimpleHttpRequest(StandardMethods.PATCH, requestUri);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest patch(final String requestUri) {
|
||||
return new SimpleHttpRequest(StandardMethods.PATCH, URI.create(requestUri));
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest patch(final HttpHost host, final String path) {
|
||||
Args.notNull(host, "Host");
|
||||
return new SimpleHttpRequest(StandardMethods.PATCH, host, path);
|
||||
}
|
||||
|
||||
public static SimpleHttpRequest copy(final HttpRequest original) {
|
||||
Args.notNull(original, "HTTP request");
|
||||
final SimpleHttpRequest copy = new SimpleHttpRequest(original.getMethod(), original.getRequestUri());
|
||||
|
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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 java.net.URI;
|
||||
|
||||
import org.apache.hc.client5.http.StandardMethods;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
|
||||
/**
|
||||
* HTTP methods defined in RFC2616.
|
||||
*
|
||||
* @since 5.0-beta2
|
||||
*/
|
||||
public enum SimpleHttpRequests {
|
||||
|
||||
DELETE {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.DELETE.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.DELETE.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
GET {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.GET.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.GET.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
HEAD {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.HEAD.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.HEAD.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
OPTIONS {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.OPTIONS.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.OPTIONS.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
PATCH {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.PATCH.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.PATCH.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
POST {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.POST.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.POST.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
PUT {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.PUT.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.PUT.name(), host, path);
|
||||
}
|
||||
},
|
||||
|
||||
TRACE {
|
||||
@Override
|
||||
public SimpleHttpRequest create(final URI uri) {
|
||||
return new SimpleHttpRequest(StandardMethods.TRACE.name(), uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleHttpRequest create(final HttpHost host, final String path) {
|
||||
return new SimpleHttpRequest(StandardMethods.TRACE.name(), host, path);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
|
||||
*
|
||||
* @param uri a non-null URI String.
|
||||
* @return a new subclass of SimpleHttpRequest
|
||||
*/
|
||||
public SimpleHttpRequest create(final String uri) {
|
||||
return create(URI.create(uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
|
||||
*
|
||||
* @param uri a non-null URI.
|
||||
* @return a new subclass of SimpleHttpRequest
|
||||
*/
|
||||
public abstract SimpleHttpRequest create(URI uri);
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
|
||||
*
|
||||
* @param host HTTP host.
|
||||
* @param path request path.
|
||||
* @return a new subclass of SimpleHttpRequest
|
||||
*/
|
||||
public abstract SimpleHttpRequest create(final HttpHost host, final String path);
|
||||
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
|
||||
/**
|
||||
* HTTP methods defined in RFC2616.
|
||||
@ -40,78 +39,78 @@ public enum ClassicHttpRequests {
|
||||
|
||||
DELETE {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpDelete(uri);
|
||||
}
|
||||
},
|
||||
|
||||
GET {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpGet(uri);
|
||||
}
|
||||
},
|
||||
|
||||
HEAD {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpHead(uri);
|
||||
}
|
||||
},
|
||||
|
||||
OPTIONS {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpOptions(uri);
|
||||
}
|
||||
},
|
||||
|
||||
PATCH {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpPatch(uri);
|
||||
}
|
||||
},
|
||||
|
||||
POST {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpPost(uri);
|
||||
}
|
||||
},
|
||||
|
||||
PUT {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpPut(uri);
|
||||
}
|
||||
},
|
||||
|
||||
TRACE {
|
||||
@Override
|
||||
public ClassicHttpRequest create(final URI uri) {
|
||||
public HttpUriRequestBase create(final URI uri) {
|
||||
return new HttpTrace(uri);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link ClassicHttpRequest}.
|
||||
* Creates a request object of the exact subclass of {@link HttpUriRequestBase}.
|
||||
*
|
||||
* @param uri
|
||||
* a non-null URI String.
|
||||
* @return a new subclass of HttpUriRequestBase
|
||||
*/
|
||||
public ClassicHttpRequest create(final String uri) {
|
||||
public HttpUriRequestBase create(final String uri) {
|
||||
return create(URI.create(uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a request object of the exact subclass of {@link ClassicHttpRequest}.
|
||||
* Creates a request object of the exact subclass of {@link HttpUriRequestBase}.
|
||||
*
|
||||
* @param uri
|
||||
* a non-null URI.
|
||||
* @return a new subclass of HttpUriRequestBase
|
||||
*/
|
||||
public abstract ClassicHttpRequest create(URI uri);
|
||||
public abstract HttpUriRequestBase create(URI uri);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user