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 2021/03/16 11:53:40 UTC
[httpcomponents-client] branch master updated: Reuse
org.apache.hc.core5.http.Method HTTP spec enum
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/master by this push:
new 879a063 Reuse org.apache.hc.core5.http.Method HTTP spec enum
879a063 is described below
commit 879a063b570bb9dd15022db01c855dc71304b0f8
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Tue Mar 16 07:05:24 2021 +0100
Reuse org.apache.hc.core5.http.Method HTTP spec enum
---
.../java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java | 5 +++--
.../java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java | 3 ++-
.../java/org/apache/hc/client5/http/impl/classic/ConnectExec.java | 3 ++-
.../java/org/apache/hc/client5/http/impl/classic/ProxyClient.java | 3 ++-
.../java/org/apache/hc/client5/http/protocol/RequestAddCookies.java | 3 ++-
.../apache/hc/client5/http/protocol/RequestClientConnControl.java | 3 ++-
.../org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java | 3 ++-
7 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java
index c65c16a..9815aab 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java
@@ -46,6 +46,7 @@ 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.HttpVersion;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
@@ -353,11 +354,11 @@ public class HttpTestUtils {
}
public static ClassicHttpRequest makeDefaultRequest() {
- return new BasicClassicHttpRequest("GET", "/");
+ return new BasicClassicHttpRequest(Method.GET.toString(), "/");
}
public static ClassicHttpRequest makeDefaultHEADRequest() {
- return new BasicClassicHttpRequest("HEAD", "/");
+ return new BasicClassicHttpRequest(Method.HEAD.toString(), "/");
}
public static ClassicHttpResponse make500Response() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
index 10f8ebf..fca3b74 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
@@ -57,6 +57,7 @@ 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.HttpVersion;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
@@ -332,7 +333,7 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
final AuthExchange proxyAuthExchange = proxy != null ? clientContext.getAuthExchange(proxy) : new AuthExchange();
- final HttpRequest connect = new BasicHttpRequest("CONNECT", nextHop, nextHop.toHostString());
+ final HttpRequest connect = new BasicHttpRequest(Method.CONNECT, nextHop, nextHop.toHostString());
connect.setVersion(HttpVersion.HTTP_1_1);
proxyHttpProcessor.process(connect, null, clientContext);
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
index e0a410a..45a7ae7 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
@@ -56,6 +56,7 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.StatusLine;
@@ -209,7 +210,7 @@ public final class ConnectExec implements ExecChainHandler {
ClassicHttpResponse response = null;
final String authority = target.toHostString();
- final ClassicHttpRequest connect = new BasicClassicHttpRequest("CONNECT", target, authority);
+ final ClassicHttpRequest connect = new BasicClassicHttpRequest(Method.CONNECT, target, authority);
connect.setVersion(HttpVersion.HTTP_1_1);
this.proxyHttpProcessor.process(connect, null, context);
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
index fa01137..b7e63ef 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
@@ -61,6 +61,7 @@ import org.apache.hc.core5.http.HttpEntity;
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.Method;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.config.Lookup;
@@ -158,7 +159,7 @@ public class ProxyClient {
final HttpContext context = new BasicHttpContext();
ClassicHttpResponse response;
- final ClassicHttpRequest connect = new BasicClassicHttpRequest("CONNECT", host.toHostString());
+ final ClassicHttpRequest connect = new BasicClassicHttpRequest(Method.CONNECT, host.toHostString());
final BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxy), credentials);
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestAddCookies.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestAddCookies.java
index a0d9261..7bd5199 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestAddCookies.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestAddCookies.java
@@ -47,6 +47,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.net.URIAuthority;
@@ -78,7 +79,7 @@ public class RequestAddCookies implements HttpRequestInterceptor {
Args.notNull(context, "HTTP context");
final String method = request.getMethod();
- if (method.equalsIgnoreCase("CONNECT") || method.equalsIgnoreCase("TRACE")) {
+ if (Method.CONNECT.isSame(method) || Method.TRACE.isSame(method)) {
return;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestClientConnControl.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestClientConnControl.java
index 563a5fb..2798c58 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestClientConnControl.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestClientConnControl.java
@@ -38,6 +38,7 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
import org.slf4j.Logger;
@@ -65,7 +66,7 @@ public class RequestClientConnControl implements HttpRequestInterceptor {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
+ if (Method.CONNECT.isSame(method)) {
return;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java
index 3f4e02c..6d31b24 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java
@@ -37,6 +37,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
@@ -68,7 +69,7 @@ public class RequestDefaultHeaders implements HttpRequestInterceptor {
Args.notNull(request, "HTTP request");
final String method = request.getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
+ if (Method.CONNECT.isSame(method)) {
return;
}