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 c65c16a42..9815aabc2 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 10f8ebff7..fca3b742f 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 e0a410acd..45a7ae762 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 fa0113776..b7e63ef8c 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 a0d926119..7bd519941 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 563a5fb7e..2798c5801 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 3f4e02c3f..6d31b24c5 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; }