Reuse org.apache.hc.core5.http.Method HTTP spec enum
This commit is contained in:
parent
10e2deb210
commit
879a063b57
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue