Changes because HttpMethod changed to class
This commit contains changes made because HttpMethod changed from enum to class. See gh-27697
This commit is contained in:
@@ -78,6 +78,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpMethod.name();
|
||||
}
|
||||
|
||||
@@ -55,10 +55,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
*/
|
||||
public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
/**
|
||||
* String representation of one of {@link HttpMethod} or not empty custom method (e.g. <i>CONNECT</i>).
|
||||
*/
|
||||
private final String httpMethod;
|
||||
private final HttpMethod httpMethod;
|
||||
|
||||
private final MultiValueMap<String, HttpCookie> cookies;
|
||||
|
||||
@@ -73,13 +70,12 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private final Flux<DataBuffer> body;
|
||||
|
||||
private MockServerHttpRequest(String httpMethod,
|
||||
private MockServerHttpRequest(HttpMethod httpMethod,
|
||||
URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
|
||||
@Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress,
|
||||
@Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
|
||||
|
||||
super(uri, contextPath, headers);
|
||||
Assert.isTrue(StringUtils.hasText(httpMethod), "HTTP method is required.");
|
||||
this.httpMethod = httpMethod;
|
||||
this.cookies = cookies;
|
||||
this.localAddress = localAddress;
|
||||
@@ -90,14 +86,14 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.resolve(this.httpMethod);
|
||||
return this.httpMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpMethod;
|
||||
return this.httpMethod.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +214,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
public static BodyBuilder method(HttpMethod method, URI url) {
|
||||
Assert.notNull(method, "HTTP method is required. " +
|
||||
"For a custom HTTP method, please provide a String HTTP method value.");
|
||||
return new DefaultBodyBuilder(method.name(), url);
|
||||
return new DefaultBodyBuilder(method, url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,9 +238,12 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
* @param vars variables to expand into the template
|
||||
* @return the created builder
|
||||
* @since 5.2.7
|
||||
* @deprecated in favor of {@link #method(HttpMethod, String, Object...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BodyBuilder method(String httpMethod, String uri, Object... vars) {
|
||||
return new DefaultBodyBuilder(httpMethod, toUri(uri, vars));
|
||||
Assert.isTrue(StringUtils.hasText(httpMethod), "HTTP method is required.");
|
||||
return new DefaultBodyBuilder(HttpMethod.valueOf(httpMethod), toUri(uri, vars));
|
||||
}
|
||||
|
||||
private static URI toUri(String uri, Object[] vars) {
|
||||
@@ -427,7 +426,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private static class DefaultBodyBuilder implements BodyBuilder {
|
||||
|
||||
private final String methodValue;
|
||||
private final HttpMethod method;
|
||||
|
||||
private final URI url;
|
||||
|
||||
@@ -449,8 +448,8 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Nullable
|
||||
private SslInfo sslInfo;
|
||||
|
||||
DefaultBodyBuilder(String method, URI url) {
|
||||
this.methodValue = method;
|
||||
DefaultBodyBuilder(HttpMethod method, URI url) {
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@@ -589,7 +588,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Override
|
||||
public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
|
||||
applyCookiesIfNecessary();
|
||||
return new MockServerHttpRequest(this.methodValue, getUrlToUse(), this.contextPath,
|
||||
return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath,
|
||||
this.headers, this.cookies, this.localAddress, this.remoteAddress, this.sslInfo, body);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -102,12 +103,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
@Override
|
||||
public List<MultipartFile> getFiles(String name) {
|
||||
List<MultipartFile> multipartFiles = this.multipartFiles.get(name);
|
||||
if (multipartFiles != null) {
|
||||
return multipartFiles;
|
||||
}
|
||||
else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Objects.requireNonNullElse(multipartFiles, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +137,9 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
|
||||
@Override
|
||||
public HttpMethod getRequestMethod() {
|
||||
return HttpMethod.resolve(getMethod());
|
||||
String method = getMethod();
|
||||
Assert.state(method != null, "Method must not be null");
|
||||
return HttpMethod.valueOf(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -132,6 +132,7 @@ public final class MockServerRequest implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -589,18 +589,19 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* Return the value of the {@code Access-Control-Allow-Methods} response header.
|
||||
*/
|
||||
public List<HttpMethod> getAccessControlAllowMethods() {
|
||||
List<HttpMethod> result = new ArrayList<>();
|
||||
String value = getFirst(ACCESS_CONTROL_ALLOW_METHODS);
|
||||
if (value != null) {
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
|
||||
List<HttpMethod> result = new ArrayList<>();
|
||||
for (String token : tokens) {
|
||||
HttpMethod resolved = HttpMethod.resolve(token);
|
||||
if (resolved != null) {
|
||||
result.add(resolved);
|
||||
}
|
||||
HttpMethod method = HttpMethod.valueOf(token);
|
||||
result.add(method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,7 +683,13 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
*/
|
||||
@Nullable
|
||||
public HttpMethod getAccessControlRequestMethod() {
|
||||
return HttpMethod.resolve(getFirst(ACCESS_CONTROL_REQUEST_METHOD));
|
||||
String requestMethod = getFirst(ACCESS_CONTROL_REQUEST_METHOD);
|
||||
if (requestMethod != null) {
|
||||
return HttpMethod.valueOf(requestMethod);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -743,17 +750,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
String value = getFirst(ALLOW);
|
||||
if (StringUtils.hasLength(value)) {
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
|
||||
List<HttpMethod> result = new ArrayList<>(tokens.length);
|
||||
Set<HttpMethod> result = new LinkedHashSet<>(tokens.length);
|
||||
for (String token : tokens) {
|
||||
HttpMethod resolved = HttpMethod.resolve(token);
|
||||
if (resolved != null) {
|
||||
result.add(resolved);
|
||||
}
|
||||
HttpMethod method = HttpMethod.valueOf(token);
|
||||
result.add(method);
|
||||
}
|
||||
return EnumSet.copyOf(result);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return EnumSet.noneOf(HttpMethod.class);
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.http;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an HTTP request message, consisting of
|
||||
* {@linkplain #getMethod() method} and {@linkplain #getURI() uri}.
|
||||
@@ -31,22 +29,20 @@ public interface HttpRequest extends HttpMessage {
|
||||
|
||||
/**
|
||||
* Return the HTTP method of the request.
|
||||
* @return the HTTP method as an HttpMethod enum value, or {@code null}
|
||||
* if not resolvable (e.g. in case of a non-standard HTTP method)
|
||||
* @see #getMethodValue()
|
||||
* @see HttpMethod#resolve(String)
|
||||
* @return the HTTP method as an HttpMethod value
|
||||
* @see HttpMethod#valueOf(String)
|
||||
*/
|
||||
@Nullable
|
||||
default HttpMethod getMethod() {
|
||||
return HttpMethod.resolve(getMethodValue());
|
||||
}
|
||||
HttpMethod getMethod();
|
||||
|
||||
/**
|
||||
* Return the HTTP method of the request as a String value.
|
||||
* @return the HTTP method as a plain String
|
||||
* @since 5.0
|
||||
* @see #getMethod()
|
||||
* @deprecated in favor of {@link #getMethod()} and
|
||||
* {@link HttpMethod#name()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getMethodValue();
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.net.URI;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -41,12 +40,12 @@ final class BufferingClientHttpRequestWrapper extends AbstractBufferingClientHtt
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return this.request.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.request.getMethodValue();
|
||||
}
|
||||
|
||||
@@ -59,8 +59,13 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
|
||||
this.httpContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.httpRequest.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpRequest.getMethod();
|
||||
}
|
||||
|
||||
@@ -273,26 +273,31 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* @return the Commons HttpMethodBase object
|
||||
*/
|
||||
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
|
||||
switch (httpMethod) {
|
||||
case GET:
|
||||
return new HttpGet(uri);
|
||||
case HEAD:
|
||||
return new HttpHead(uri);
|
||||
case POST:
|
||||
return new HttpPost(uri);
|
||||
case PUT:
|
||||
return new HttpPut(uri);
|
||||
case PATCH:
|
||||
return new HttpPatch(uri);
|
||||
case DELETE:
|
||||
return new HttpDelete(uri);
|
||||
case OPTIONS:
|
||||
return new HttpOptions(uri);
|
||||
case TRACE:
|
||||
return new HttpTrace(uri);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
|
||||
if (HttpMethod.GET.equals(httpMethod)) {
|
||||
return new HttpGet(uri);
|
||||
}
|
||||
else if (HttpMethod.HEAD.equals(httpMethod)) {
|
||||
return new HttpHead(uri);
|
||||
}
|
||||
else if (HttpMethod.POST.equals(httpMethod)) {
|
||||
return new HttpPost(uri);
|
||||
}
|
||||
else if (HttpMethod.PUT.equals(httpMethod)) {
|
||||
return new HttpPut(uri);
|
||||
}
|
||||
else if (HttpMethod.PATCH.equals(httpMethod)) {
|
||||
return new HttpPatch(uri);
|
||||
}
|
||||
else if (HttpMethod.DELETE.equals(httpMethod)) {
|
||||
return new HttpDelete(uri);
|
||||
}
|
||||
else if (HttpMethod.OPTIONS.equals(httpMethod)) {
|
||||
return new HttpOptions(uri);
|
||||
}
|
||||
else if (HttpMethod.TRACE.equals(httpMethod)) {
|
||||
return new HttpTrace(uri);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -64,8 +65,13 @@ final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpR
|
||||
this.httpContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.httpRequest.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpRequest.getMethod();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -62,6 +61,7 @@ class InterceptingClientHttpRequest extends AbstractBufferingClientHttpRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.method.name();
|
||||
}
|
||||
@@ -94,7 +94,6 @@ class InterceptingClientHttpRequest extends AbstractBufferingClientHttpRequest {
|
||||
}
|
||||
else {
|
||||
HttpMethod method = request.getMethod();
|
||||
Assert.state(method != null, "No standard HTTP method");
|
||||
ClientHttpRequest delegate = requestFactory.createRequest(request.getURI(), method);
|
||||
request.getHeaders().forEach((key, value) -> delegate.getHeaders().addAll(key, value));
|
||||
if (body.length > 0) {
|
||||
|
||||
@@ -57,6 +57,7 @@ class OkHttp3ClientHttpRequest extends AbstractBufferingClientHttpRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@@ -47,8 +47,13 @@ final class SimpleBufferingClientHttpRequest extends AbstractBufferingClientHttp
|
||||
this.outputStreaming = outputStreaming;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.connection.getRequestMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.connection.getRequestMethod();
|
||||
}
|
||||
|
||||
@@ -55,8 +55,13 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest {
|
||||
this.outputStreaming = outputStreaming;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.connection.getRequestMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.connection.getRequestMethod();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.springframework.http.MediaType.ALL_VALUE;
|
||||
|
||||
@@ -74,9 +73,7 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
HttpMethod method = HttpMethod.resolve(this.httpRequest.getMethod());
|
||||
Assert.state(method != null, "Method must not be null");
|
||||
return method;
|
||||
return HttpMethod.valueOf(this.httpRequest.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.net.URI;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,6 @@ public class HttpRequestWrapper implements HttpRequest {
|
||||
* Return the method of the wrapped request.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return this.request.getMethod();
|
||||
}
|
||||
@@ -68,6 +66,7 @@ public class HttpRequestWrapper implements HttpRequest {
|
||||
* Return the method value of the wrapped request.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.request.getMethodValue();
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.resolve(this.servletRequest.getMethod());
|
||||
return HttpMethod.valueOf(this.servletRequest.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.servletRequest.getMethod();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
private String httpMethodValue;
|
||||
private HttpMethod httpMethod;
|
||||
|
||||
@Nullable
|
||||
private String uriPath;
|
||||
@@ -71,7 +71,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
this.uri = original.getURI();
|
||||
this.headers = HttpHeaders.writableHttpHeaders(original.getHeaders());
|
||||
this.httpMethodValue = original.getMethodValue();
|
||||
this.httpMethod = original.getMethod();
|
||||
this.contextPath = original.getPath().contextPath().value();
|
||||
this.remoteAddress = original.getRemoteAddress();
|
||||
this.body = original.getBody();
|
||||
@@ -81,7 +81,8 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
@Override
|
||||
public ServerHttpRequest.Builder method(HttpMethod httpMethod) {
|
||||
this.httpMethodValue = httpMethod.name();
|
||||
Assert.notNull(httpMethod, "HttpMethod must not be null");
|
||||
this.httpMethod = httpMethod;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
@Override
|
||||
public ServerHttpRequest build() {
|
||||
return new MutatedServerHttpRequest(getUriToUse(), this.contextPath,
|
||||
this.httpMethodValue, this.sslInfo, this.remoteAddress, this.headers, this.body, this.originalRequest);
|
||||
this.httpMethod, this.sslInfo, this.remoteAddress, this.headers, this.body, this.originalRequest);
|
||||
}
|
||||
|
||||
private URI getUriToUse() {
|
||||
@@ -176,7 +177,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
private static class MutatedServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private final String methodValue;
|
||||
private final HttpMethod method;
|
||||
|
||||
@Nullable
|
||||
private final SslInfo sslInfo;
|
||||
@@ -190,11 +191,11 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
|
||||
public MutatedServerHttpRequest(URI uri, @Nullable String contextPath,
|
||||
String methodValue, @Nullable SslInfo sslInfo, @Nullable InetSocketAddress remoteAddress,
|
||||
HttpMethod method, @Nullable SslInfo sslInfo, @Nullable InetSocketAddress remoteAddress,
|
||||
HttpHeaders headers, Flux<DataBuffer> body, ServerHttpRequest originalRequest) {
|
||||
|
||||
super(uri, contextPath, headers);
|
||||
this.methodValue = methodValue;
|
||||
this.method = method;
|
||||
this.remoteAddress = (remoteAddress != null ? remoteAddress : originalRequest.getRemoteAddress());
|
||||
this.sslInfo = (sslInfo != null ? sslInfo : originalRequest.getSslInfo());
|
||||
this.body = body;
|
||||
@@ -202,8 +203,14 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.methodValue;
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpLogging;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -138,8 +139,13 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.request.method().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.request.method().name();
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ public class ServerHttpRequestDecorator implements ServerHttpRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return getDelegate().getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return getDelegate().getMethodValue();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -158,8 +159,13 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return (headers != null ? headers : headerValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.request.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.request.getMethod();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import reactor.core.publisher.Flux;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -77,6 +78,12 @@ class UndertowServerHttpRequest extends AbstractServerHttpRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf(this.exchange.getRequestMethod().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.exchange.getRequestMethod().toString();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package org.springframework.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -117,14 +115,12 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
|
||||
if (this.supportedMethods == null) {
|
||||
return null;
|
||||
}
|
||||
List<HttpMethod> supportedMethods = new ArrayList<>(this.supportedMethods.length);
|
||||
Set<HttpMethod> supportedMethods = new LinkedHashSet<>(this.supportedMethods.length);
|
||||
for (String value : this.supportedMethods) {
|
||||
HttpMethod resolved = HttpMethod.resolve(value);
|
||||
if (resolved != null) {
|
||||
supportedMethods.add(resolved);
|
||||
}
|
||||
HttpMethod method = HttpMethod.valueOf(value);
|
||||
supportedMethods.add(method);
|
||||
}
|
||||
return EnumSet.copyOf(supportedMethods);
|
||||
return supportedMethods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -118,9 +118,8 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||
* Return the HTTP method of the request.
|
||||
* @since 4.0.2
|
||||
*/
|
||||
@Nullable
|
||||
public HttpMethod getHttpMethod() {
|
||||
return HttpMethod.resolve(getRequest().getMethod());
|
||||
return HttpMethod.valueOf(getRequest().getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -258,7 +258,7 @@ public class CorsConfiguration {
|
||||
this.resolvedMethods = null;
|
||||
break;
|
||||
}
|
||||
this.resolvedMethods.add(HttpMethod.resolve(method));
|
||||
this.resolvedMethods.add(HttpMethod.valueOf(method));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -302,7 +302,7 @@ public class CorsConfiguration {
|
||||
this.resolvedMethods = null;
|
||||
}
|
||||
else if (this.resolvedMethods != null) {
|
||||
this.resolvedMethods.add(HttpMethod.resolve(method));
|
||||
this.resolvedMethods.add(HttpMethod.valueOf(method));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -447,7 +447,7 @@ public class CorsConfiguration {
|
||||
if (this.allowedMethods == null) {
|
||||
this.allowedMethods = DEFAULT_PERMIT_METHODS;
|
||||
this.resolvedMethods = DEFAULT_PERMIT_METHODS
|
||||
.stream().map(HttpMethod::resolve).collect(Collectors.toList());
|
||||
.stream().map(HttpMethod::valueOf).collect(Collectors.toList());
|
||||
}
|
||||
if (this.allowedHeaders == null) {
|
||||
this.allowedHeaders = DEFAULT_PERMIT_ALL;
|
||||
|
||||
@@ -91,8 +91,7 @@ public class HiddenHttpMethodFilter implements WebFilter {
|
||||
}
|
||||
|
||||
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) {
|
||||
HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH));
|
||||
Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported");
|
||||
HttpMethod httpMethod = HttpMethod.valueOf(methodParamValue.toUpperCase(Locale.ENGLISH));
|
||||
if (ALLOWED_METHODS.contains(httpMethod)) {
|
||||
return exchange.mutate().request(builder -> builder.method(httpMethod)).build();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public interface MultipartHttpServletRequest extends HttpServletRequest, Multipa
|
||||
/**
|
||||
* Return this request's method as a convenient HttpMethod instance.
|
||||
*/
|
||||
@Nullable
|
||||
HttpMethod getRequestMethod();
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractMultipartHttpServletRequest extends HttpServletReq
|
||||
|
||||
@Override
|
||||
public HttpMethod getRequestMethod() {
|
||||
return HttpMethod.resolve(getRequest().getMethod());
|
||||
return HttpMethod.valueOf(getRequest().getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,8 @@ import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
@@ -129,7 +129,7 @@ public class HttpHeadersTests {
|
||||
|
||||
@Test
|
||||
void allow() {
|
||||
EnumSet<HttpMethod> methods = EnumSet.of(HttpMethod.GET, HttpMethod.POST);
|
||||
Set<HttpMethod> methods = new LinkedHashSet<>(Arrays.asList(HttpMethod.GET, HttpMethod.POST));
|
||||
headers.setAllow(methods);
|
||||
assertThat(headers.getAllow()).as("Invalid Allow header").isEqualTo(methods);
|
||||
assertThat(headers.getFirst("Allow")).as("Invalid Allow header").isEqualTo("GET,POST");
|
||||
|
||||
@@ -268,6 +268,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return method.name();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class ClientHttpConnectorTests {
|
||||
|
||||
private static final int BUF_SIZE = 1024;
|
||||
|
||||
private static final EnumSet<HttpMethod> METHODS_WITH_BODY =
|
||||
EnumSet.of(HttpMethod.PUT, HttpMethod.POST, HttpMethod.PATCH);
|
||||
private static final Set<HttpMethod> METHODS_WITH_BODY =
|
||||
Set.of(HttpMethod.PUT, HttpMethod.POST, HttpMethod.PATCH);
|
||||
|
||||
private final MockWebServer server = new MockWebServer();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.lang.annotation.Target;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
@@ -275,7 +274,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
||||
setUpClient(clientHttpRequestFactory);
|
||||
|
||||
Set<HttpMethod> allowed = template.optionsForAllow(new URI(baseUrl + "/get"));
|
||||
assertThat(allowed).as("Invalid response").isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE));
|
||||
assertThat(allowed).as("Invalid response").isEqualTo(Set.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE));
|
||||
}
|
||||
|
||||
@ParameterizedRestTemplateTest
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -580,7 +579,7 @@ class RestTemplateTests {
|
||||
mockSentRequest(OPTIONS, "https://example.com");
|
||||
mockResponseStatus(HttpStatus.OK);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
EnumSet<HttpMethod> expected = EnumSet.of(GET, POST);
|
||||
Set<HttpMethod> expected = Set.of(GET, POST);
|
||||
responseHeaders.setAllow(expected);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -75,16 +74,6 @@ public class HiddenHttpMethodFilterTests {
|
||||
assertThat(this.filterChain.getHttpMethod()).isEqualTo(HttpMethod.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWithInvalidMethodValue() {
|
||||
StepVerifier.create(postForm("_method=INVALID"))
|
||||
.consumeErrorWith(error -> {
|
||||
assertThat(error).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(error.getMessage()).isEqualTo("HttpMethod 'INVALID' not supported");
|
||||
})
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWithHttpPut() {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -680,6 +681,12 @@ class UriComponentsBuilderTests {
|
||||
void fromHttpRequestWithEmptyScheme() {
|
||||
HttpRequest request = new HttpRequest() {
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.GET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return "GET";
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ import org.springframework.core.annotation.SynthesizingMethodParameter
|
||||
import org.springframework.core.convert.support.DefaultConversionService
|
||||
import org.springframework.http.HttpMethod
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletResponse
|
||||
import org.springframework.web.testfixture.servlet.MockMultipartFile
|
||||
import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest
|
||||
import org.springframework.util.ReflectionUtils
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
@@ -39,6 +35,10 @@ import org.springframework.web.context.request.NativeWebRequest
|
||||
import org.springframework.web.context.request.ServletWebRequest
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import org.springframework.web.multipart.support.MissingServletRequestPartException
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletResponse
|
||||
import org.springframework.web.testfixture.servlet.MockMultipartFile
|
||||
import org.springframework.web.testfixture.servlet.MockMultipartHttpServletRequest
|
||||
|
||||
/**
|
||||
* Kotlin test fixture for [RequestParamMethodArgumentResolver].
|
||||
@@ -156,7 +156,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
||||
|
||||
@Test
|
||||
fun resolveNullableRequiredWithoutMultipartParameter() {
|
||||
request.method = HttpMethod.POST.name
|
||||
request.method = HttpMethod.POST.name()
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamRequired, null, webRequest, binderFactory)
|
||||
@@ -176,7 +176,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
||||
|
||||
@Test
|
||||
fun resolveNullableNotRequiredWithoutMultipartParameter() {
|
||||
request.method = HttpMethod.POST.name
|
||||
request.method = HttpMethod.POST.name()
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
var result = resolver.resolveArgument(nullableMultipartParamNotRequired, null, webRequest, binderFactory)
|
||||
@@ -196,7 +196,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
||||
|
||||
@Test
|
||||
fun resolveNonNullableRequiredWithoutMultipartParameter() {
|
||||
request.method = HttpMethod.POST.name
|
||||
request.method = HttpMethod.POST.name()
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
assertThatExceptionOfType(MissingServletRequestPartException::class.java).isThrownBy {
|
||||
@@ -217,7 +217,7 @@ class RequestParamMethodArgumentResolverKotlinTests {
|
||||
|
||||
@Test
|
||||
fun resolveNonNullableNotRequiredWithoutMultipartParameter() {
|
||||
request.method = HttpMethod.POST.name
|
||||
request.method = HttpMethod.POST.name()
|
||||
request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
|
||||
assertThatExceptionOfType(NullPointerException::class.java).isThrownBy {
|
||||
|
||||
@@ -96,6 +96,7 @@ public class MockClientHttpRequest extends AbstractClientHttpRequest implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpMethod.name();
|
||||
}
|
||||
|
||||
@@ -55,10 +55,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
*/
|
||||
public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
/**
|
||||
* String representation of one of {@link HttpMethod} or not empty custom method (e.g. <i>CONNECT</i>).
|
||||
*/
|
||||
private final String httpMethod;
|
||||
private final HttpMethod httpMethod;
|
||||
|
||||
private final MultiValueMap<String, HttpCookie> cookies;
|
||||
|
||||
@@ -73,13 +70,12 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private final Flux<DataBuffer> body;
|
||||
|
||||
private MockServerHttpRequest(String httpMethod,
|
||||
private MockServerHttpRequest(HttpMethod httpMethod,
|
||||
URI uri, @Nullable String contextPath, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
|
||||
@Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress,
|
||||
@Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
|
||||
|
||||
super(uri, contextPath, headers);
|
||||
Assert.isTrue(StringUtils.hasText(httpMethod), "HTTP method is required.");
|
||||
this.httpMethod = httpMethod;
|
||||
this.cookies = cookies;
|
||||
this.localAddress = localAddress;
|
||||
@@ -90,14 +86,14 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.resolve(this.httpMethod);
|
||||
return this.httpMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.httpMethod;
|
||||
return this.httpMethod.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +214,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
public static BodyBuilder method(HttpMethod method, URI url) {
|
||||
Assert.notNull(method, "HTTP method is required. " +
|
||||
"For a custom HTTP method, please provide a String HTTP method value.");
|
||||
return new DefaultBodyBuilder(method.name(), url);
|
||||
return new DefaultBodyBuilder(method, url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,9 +238,12 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
* @param vars variables to expand into the template
|
||||
* @return the created builder
|
||||
* @since 5.2.7
|
||||
* @deprecated in favor of {@link #method(HttpMethod, String, Object...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BodyBuilder method(String httpMethod, String uri, Object... vars) {
|
||||
return new DefaultBodyBuilder(httpMethod, toUri(uri, vars));
|
||||
Assert.isTrue(StringUtils.hasText(httpMethod), "HTTP method is required.");
|
||||
return new DefaultBodyBuilder(HttpMethod.valueOf(httpMethod), toUri(uri, vars));
|
||||
}
|
||||
|
||||
private static URI toUri(String uri, Object[] vars) {
|
||||
@@ -427,7 +426,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private static class DefaultBodyBuilder implements BodyBuilder {
|
||||
|
||||
private final String methodValue;
|
||||
private final HttpMethod method;
|
||||
|
||||
private final URI url;
|
||||
|
||||
@@ -449,8 +448,8 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Nullable
|
||||
private SslInfo sslInfo;
|
||||
|
||||
DefaultBodyBuilder(String method, URI url) {
|
||||
this.methodValue = method;
|
||||
DefaultBodyBuilder(HttpMethod method, URI url) {
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@@ -589,7 +588,7 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
@Override
|
||||
public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
|
||||
applyCookiesIfNecessary();
|
||||
return new MockServerHttpRequest(this.methodValue, getUrlToUse(), this.contextPath,
|
||||
return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath,
|
||||
this.headers, this.cookies, this.localAddress, this.remoteAddress, this.sslInfo, body);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,13 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
|
||||
@Override
|
||||
public HttpMethod getRequestMethod() {
|
||||
return HttpMethod.resolve(getMethod());
|
||||
String method = getMethod();
|
||||
if (method != null) {
|
||||
return HttpMethod.valueOf(method);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
@@ -50,6 +51,12 @@ final class DefaultClientResponseBuilder implements ClientResponse.Builder {
|
||||
private final URI empty = URI.create("");
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.valueOf("UNKNOWN");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
@@ -210,7 +217,7 @@ final class DefaultClientResponseBuilder implements ClientResponse.Builder {
|
||||
|
||||
return new DefaultClientResponse(httpResponse, this.strategies,
|
||||
this.originalResponse != null ? this.originalResponse.logPrefix() : "",
|
||||
this.request.getMethodValue() + " " + this.request.getURI(),
|
||||
this.request.getMethod() + " " + this.request.getURI(),
|
||||
() -> this.request);
|
||||
}
|
||||
|
||||
|
||||
@@ -378,6 +378,7 @@ class DefaultWebClient implements WebClient {
|
||||
return httpMethod;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return httpMethod.name();
|
||||
}
|
||||
@@ -667,7 +668,7 @@ class DefaultWebClient implements WebClient {
|
||||
}
|
||||
|
||||
private <T> Mono<T> insertCheckpoint(Mono<T> result, int statusCode, HttpRequest request) {
|
||||
String httpMethod = request.getMethodValue();
|
||||
HttpMethod httpMethod = request.getMethod();
|
||||
URI uri = request.getURI();
|
||||
String description = statusCode + " from " + httpMethod + " " + uri + " [DefaultWebClient]";
|
||||
return result.checkpoint(description);
|
||||
|
||||
@@ -150,6 +150,7 @@ public abstract class ExchangeFunctions {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return request.method().name();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class WebClientResponseException extends WebClientException {
|
||||
|
||||
private static String initMessage(int status, String reasonPhrase, @Nullable HttpRequest request) {
|
||||
return status + " " + reasonPhrase +
|
||||
(request != null ? " from " + request.getMethodValue() + " " + request.getURI() : "");
|
||||
(request != null ? " from " + request.getMethod() + " " + request.getURI() : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.core.codec.Hints;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
@@ -108,8 +109,14 @@ class DefaultServerRequest implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod method() {
|
||||
return request().getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return request().getMethodValue();
|
||||
return request().getMethod().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,7 +71,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
|
||||
private final ServerWebExchange exchange;
|
||||
|
||||
private String methodName;
|
||||
private HttpMethod method;
|
||||
|
||||
private URI uri;
|
||||
|
||||
@@ -88,7 +88,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
Assert.notNull(other, "ServerRequest must not be null");
|
||||
this.messageReaders = other.messageReaders();
|
||||
this.exchange = other.exchange();
|
||||
this.methodName = other.methodName();
|
||||
this.method = other.method();
|
||||
this.uri = other.uri();
|
||||
this.headers.addAll(other.headers().asHttpHeaders());
|
||||
this.cookies.addAll(other.cookies());
|
||||
@@ -99,7 +99,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
@Override
|
||||
public ServerRequest.Builder method(HttpMethod method) {
|
||||
Assert.notNull(method, "HttpMethod must not be null");
|
||||
this.methodName = method.name();
|
||||
this.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
@Override
|
||||
public ServerRequest build() {
|
||||
ServerHttpRequest serverHttpRequest = new BuiltServerHttpRequest(this.exchange.getRequest().getId(),
|
||||
this.methodName, this.uri, this.headers, this.cookies, this.body);
|
||||
this.method, this.uri, this.headers, this.cookies, this.body);
|
||||
ServerWebExchange exchange = new DelegatingServerWebExchange(
|
||||
serverHttpRequest, this.attributes, this.exchange, this.messageReaders);
|
||||
return new DefaultServerRequest(exchange, this.messageReaders);
|
||||
@@ -190,7 +190,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String method;
|
||||
private final HttpMethod method;
|
||||
|
||||
private final URI uri;
|
||||
|
||||
@@ -204,7 +204,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
|
||||
private final Flux<DataBuffer> body;
|
||||
|
||||
public BuiltServerHttpRequest(String id, String method, URI uri, HttpHeaders headers,
|
||||
public BuiltServerHttpRequest(String id, HttpMethod method, URI uri, HttpHeaders headers,
|
||||
MultiValueMap<String, HttpCookie> cookies, Flux<DataBuffer> body) {
|
||||
|
||||
this.id = id;
|
||||
@@ -248,10 +248,16 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodValue() {
|
||||
public HttpMethod getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMethodValue() {
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return this.uri;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -297,7 +296,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
|
||||
*/
|
||||
abstract static class AbstractServerResponse implements ServerResponse {
|
||||
|
||||
private static final Set<HttpMethod> SAFE_METHODS = EnumSet.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
private static final Set<HttpMethod> SAFE_METHODS = Set.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
final int statusCode;
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.net.URI;
|
||||
import java.security.Principal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -437,12 +437,12 @@ public abstract class RequestPredicates {
|
||||
|
||||
public HttpMethodPredicate(HttpMethod httpMethod) {
|
||||
Assert.notNull(httpMethod, "HttpMethod must not be null");
|
||||
this.httpMethods = EnumSet.of(httpMethod);
|
||||
this.httpMethods = Collections.singleton(httpMethod);
|
||||
}
|
||||
|
||||
public HttpMethodPredicate(HttpMethod... httpMethods) {
|
||||
Assert.notEmpty(httpMethods, "HttpMethods must not be empty");
|
||||
this.httpMethods = EnumSet.copyOf(Arrays.asList(httpMethods));
|
||||
this.httpMethods = new LinkedHashSet<>(Arrays.asList(httpMethods));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -453,16 +453,15 @@ public abstract class RequestPredicates {
|
||||
return match;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static HttpMethod method(ServerRequest request) {
|
||||
if (CorsUtils.isPreFlightRequest(request.exchange().getRequest())) {
|
||||
String accessControlRequestMethod =
|
||||
request.headers().firstHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD);
|
||||
return HttpMethod.resolve(accessControlRequestMethod);
|
||||
}
|
||||
else {
|
||||
return request.method();
|
||||
if (accessControlRequestMethod != null) {
|
||||
return HttpMethod.valueOf(accessControlRequestMethod);
|
||||
}
|
||||
}
|
||||
return request.method();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -968,6 +967,7 @@ public abstract class RequestPredicates {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return this.request.methodName();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -42,7 +41,7 @@ import org.springframework.web.reactive.function.BodyInserters;
|
||||
class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
|
||||
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS =
|
||||
EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS);
|
||||
Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS);
|
||||
|
||||
|
||||
private final Resource resource;
|
||||
@@ -56,20 +55,19 @@ class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
|
||||
@Override
|
||||
public Mono<ServerResponse> handle(ServerRequest request) {
|
||||
HttpMethod method = request.method();
|
||||
if (method != null) {
|
||||
switch (method) {
|
||||
case GET:
|
||||
return EntityResponse.fromObject(this.resource).build()
|
||||
.map(response -> response);
|
||||
case HEAD:
|
||||
Resource headResource = new HeadMethodResource(this.resource);
|
||||
return EntityResponse.fromObject(headResource).build()
|
||||
.map(response -> response);
|
||||
case OPTIONS:
|
||||
return ServerResponse.ok()
|
||||
.allow(SUPPORTED_METHODS)
|
||||
.body(BodyInserters.empty());
|
||||
}
|
||||
if (HttpMethod.GET.equals(method)) {
|
||||
return EntityResponse.fromObject(this.resource).build()
|
||||
.map(response -> response);
|
||||
}
|
||||
else if (HttpMethod.HEAD.equals(method)) {
|
||||
Resource headResource = new HeadMethodResource(this.resource);
|
||||
return EntityResponse.fromObject(headResource).build()
|
||||
.map(response -> response);
|
||||
}
|
||||
else if (HttpMethod.OPTIONS.equals(method)) {
|
||||
return ServerResponse.ok()
|
||||
.allow(SUPPORTED_METHODS)
|
||||
.body(BodyInserters.empty());
|
||||
}
|
||||
return ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.allow(SUPPORTED_METHODS)
|
||||
|
||||
@@ -70,15 +70,14 @@ public interface ServerRequest {
|
||||
* @return the HTTP method as an HttpMethod enum value, or {@code null}
|
||||
* if not resolvable (e.g. in case of a non-standard HTTP method)
|
||||
*/
|
||||
@Nullable
|
||||
default HttpMethod method() {
|
||||
return HttpMethod.resolve(methodName());
|
||||
}
|
||||
HttpMethod method();
|
||||
|
||||
/**
|
||||
* Get the name of the HTTP method.
|
||||
* @return the HTTP method as a String
|
||||
* @deprecated in favor of {@link #method()}
|
||||
*/
|
||||
@Deprecated
|
||||
String methodName();
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,6 +85,7 @@ public class ServerRequestWrapper implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return this.delegate.methodName();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -90,7 +89,7 @@ import org.springframework.web.server.WebHandler;
|
||||
*/
|
||||
public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS = EnumSet.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS = Set.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ResourceWebHandler.class);
|
||||
|
||||
@@ -407,7 +406,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
}))
|
||||
.flatMap(resource -> {
|
||||
try {
|
||||
if (HttpMethod.OPTIONS.matches(exchange.getRequest().getMethodValue())) {
|
||||
if (HttpMethod.OPTIONS.equals(exchange.getRequest().getMethod())) {
|
||||
exchange.getResponse().getHeaders().add("Allow", "GET,HEAD,OPTIONS");
|
||||
return Mono.empty();
|
||||
}
|
||||
@@ -416,7 +415,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
HttpMethod httpMethod = exchange.getRequest().getMethod();
|
||||
if (!SUPPORTED_METHODS.contains(httpMethod)) {
|
||||
return Mono.error(new MethodNotAllowedException(
|
||||
exchange.getRequest().getMethodValue(), SUPPORTED_METHODS));
|
||||
exchange.getRequest().getMethod(), SUPPORTED_METHODS));
|
||||
}
|
||||
|
||||
// Header phase
|
||||
|
||||
@@ -127,7 +127,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
|
||||
return matchPreFlight(exchange.getRequest());
|
||||
}
|
||||
if (getMethods().isEmpty()) {
|
||||
if (RequestMethod.OPTIONS.name().equals(exchange.getRequest().getMethodValue())) {
|
||||
if (HttpMethod.OPTIONS.equals(exchange.getRequest().getMethod())) {
|
||||
return null; // We handle OPTIONS transparently, so don't match if no explicit declarations
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -20,12 +20,12 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -171,9 +171,9 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
|
||||
if (helper.hasMethodsMismatch()) {
|
||||
String httpMethod = request.getMethodValue();
|
||||
HttpMethod httpMethod = request.getMethod();
|
||||
Set<HttpMethod> methods = helper.getAllowedMethods();
|
||||
if (HttpMethod.OPTIONS.matches(httpMethod)) {
|
||||
if (HttpMethod.OPTIONS.equals(httpMethod)) {
|
||||
Set<MediaType> mediaTypes = helper.getConsumablePatchMediaTypes();
|
||||
HttpOptionsHandler handler = new HttpOptionsHandler(methods, mediaTypes);
|
||||
return new HandlerMethod(handler, HTTP_OPTIONS_HANDLE_METHOD);
|
||||
@@ -269,7 +269,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
public Set<HttpMethod> getAllowedMethods() {
|
||||
return this.partialMatches.stream().
|
||||
flatMap(m -> m.getInfo().getMethodsCondition().getMethods().stream()).
|
||||
map(requestMethod -> HttpMethod.resolve(requestMethod.name())).
|
||||
map(requestMethod -> HttpMethod.valueOf(requestMethod.name())).
|
||||
collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@@ -392,8 +392,8 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
|
||||
private static Set<HttpMethod> initAllowedHttpMethods(Set<HttpMethod> declaredMethods) {
|
||||
if (declaredMethods.isEmpty()) {
|
||||
return EnumSet.allOf(HttpMethod.class).stream()
|
||||
.filter(method -> method != HttpMethod.TRACE)
|
||||
return Stream.of(HttpMethod.values())
|
||||
.filter(method -> !HttpMethod.TRACE.equals(method))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -70,7 +69,7 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
public abstract class AbstractMessageReaderArgumentResolver extends HandlerMethodArgumentResolverSupport {
|
||||
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS =
|
||||
EnumSet.of(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH);
|
||||
Set.of(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH);
|
||||
|
||||
|
||||
private final List<HttpMessageReader<?>> messageReaders;
|
||||
@@ -203,7 +202,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
// No compatible reader but body may be empty..
|
||||
|
||||
HttpMethod method = request.getMethod();
|
||||
if (contentType == null && method != null && SUPPORTED_METHODS.contains(method)) {
|
||||
if (contentType == null && SUPPORTED_METHODS.contains(method)) {
|
||||
Flux<DataBuffer> body = request.getBody().doOnNext(buffer -> {
|
||||
DataBufferUtils.release(buffer);
|
||||
// Body not empty, back toy 415..
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -52,7 +51,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*/
|
||||
public class ResponseEntityResultHandler extends AbstractMessageWriterResultHandler implements HandlerResultHandler {
|
||||
|
||||
private static final Set<HttpMethod> SAFE_METHODS = EnumSet.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
private static final Set<HttpMethod> SAFE_METHODS = Set.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -214,7 +214,7 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
|
||||
|
||||
if (HttpMethod.GET != method) {
|
||||
return Mono.error(new MethodNotAllowedException(
|
||||
request.getMethodValue(), Collections.singleton(HttpMethod.GET)));
|
||||
request.getMethod(), Collections.singleton(HttpMethod.GET)));
|
||||
}
|
||||
|
||||
if (!"WebSocket".equalsIgnoreCase(headers.getUpgrade())) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.reactive.socket.server.support;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -35,9 +36,9 @@ public class WebSocketUpgradeHandlerPredicate implements BiPredicate<Object, Ser
|
||||
@Override
|
||||
public boolean test(Object handler, ServerWebExchange exchange) {
|
||||
if (handler instanceof WebSocketHandler) {
|
||||
String method = exchange.getRequest().getMethodValue();
|
||||
HttpMethod method = exchange.getRequest().getMethod();
|
||||
String header = exchange.getRequest().getHeaders().getUpgrade();
|
||||
return (method.equals("GET") && header != null && header.equalsIgnoreCase("websocket"));
|
||||
return (HttpMethod.GET.equals(method) && header != null && header.equalsIgnoreCase("websocket"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -100,7 +99,7 @@ public class DefaultEntityResponseBuilderTests {
|
||||
public void allow() {
|
||||
String body = "foo";
|
||||
Mono<EntityResponse<String>> result = EntityResponse.fromObject(body).allow(HttpMethod.GET).build();
|
||||
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
|
||||
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(response -> expected.equals(response.headers().getAllow()))
|
||||
.expectComplete()
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -198,7 +197,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
@Test
|
||||
public void allow() {
|
||||
Mono<ServerResponse> result = ServerResponse.ok().allow(HttpMethod.GET).build();
|
||||
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
|
||||
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(response -> expected.equals(response.headers().getAllow()))
|
||||
.expectComplete()
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.reactive.function.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -141,7 +141,7 @@ public class ResourceHandlerFunctionTests {
|
||||
Mono<ServerResponse> responseMono = this.handlerFunction.handle(request);
|
||||
Mono<Void> result = responseMono.flatMap(response -> {
|
||||
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.headers().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
assertThat(response.headers().getAllow()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
return response.writeTo(exchange, context);
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ResourceHandlerFunctionTests {
|
||||
.expectComplete()
|
||||
.verify();
|
||||
assertThat(mockResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(mockResponse.getHeaders().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
assertThat(mockResponse.getHeaders().getAllow()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
|
||||
StepVerifier.create(mockResponse.getBody()).expectComplete().verify();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -141,7 +140,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
Mono<Object> mono = this.handlerMapping.getHandler(exchange);
|
||||
|
||||
assertError(mono, MethodNotAllowedException.class,
|
||||
ex -> assertThat(ex.getSupportedMethods()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD)));
|
||||
ex -> assertThat(ex.getSupportedMethods()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD)));
|
||||
}
|
||||
|
||||
@Test // SPR-9603
|
||||
@@ -194,11 +193,11 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
List<HttpMethod> allMethodExceptTrace = new ArrayList<>(Arrays.asList(HttpMethod.values()));
|
||||
allMethodExceptTrace.remove(HttpMethod.TRACE);
|
||||
|
||||
testHttpOptions("/foo", EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS), null);
|
||||
testHttpOptions("/person/1", EnumSet.of(HttpMethod.PUT, HttpMethod.OPTIONS), null);
|
||||
testHttpOptions("/persons", EnumSet.copyOf(allMethodExceptTrace), null);
|
||||
testHttpOptions("/something", EnumSet.of(HttpMethod.PUT, HttpMethod.POST), null);
|
||||
testHttpOptions("/qux", EnumSet.of(HttpMethod.PATCH,HttpMethod.GET,HttpMethod.HEAD,HttpMethod.OPTIONS),
|
||||
testHttpOptions("/foo", Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS), null);
|
||||
testHttpOptions("/person/1", Set.of(HttpMethod.PUT, HttpMethod.OPTIONS), null);
|
||||
testHttpOptions("/persons", Set.copyOf(allMethodExceptTrace), null);
|
||||
testHttpOptions("/something", Set.of(HttpMethod.PUT, HttpMethod.POST), null);
|
||||
testHttpOptions("/qux", Set.of(HttpMethod.PATCH,HttpMethod.GET,HttpMethod.HEAD,HttpMethod.OPTIONS),
|
||||
new MediaType("foo", "bar"));
|
||||
}
|
||||
|
||||
|
||||
@@ -872,8 +872,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
protected void service(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
HttpMethod httpMethod = HttpMethod.resolve(request.getMethod());
|
||||
if (httpMethod == HttpMethod.PATCH || httpMethod == null) {
|
||||
HttpMethod httpMethod = HttpMethod.valueOf(request.getMethod());
|
||||
if (HttpMethod.PATCH.equals(httpMethod)) {
|
||||
processRequest(request, response);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.function;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -44,7 +43,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
*/
|
||||
abstract class AbstractServerResponse extends ErrorHandlingServerResponse {
|
||||
|
||||
private static final Set<HttpMethod> SAFE_METHODS = EnumSet.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
private static final Set<HttpMethod> SAFE_METHODS = Set.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
final int statusCode;
|
||||
|
||||
@@ -90,7 +89,7 @@ abstract class AbstractServerResponse extends ErrorHandlingServerResponse {
|
||||
|
||||
long lastModified = headers().getLastModified();
|
||||
ServletWebRequest servletWebRequest = new ServletWebRequest(request, response);
|
||||
HttpMethod httpMethod = HttpMethod.resolve(request.getMethod());
|
||||
HttpMethod httpMethod = HttpMethod.valueOf(request.getMethod());
|
||||
if (SAFE_METHODS.contains(httpMethod) &&
|
||||
servletWebRequest.checkNotModified(headers().getETag(), lastModified)) {
|
||||
return null;
|
||||
|
||||
@@ -48,6 +48,7 @@ import jakarta.servlet.http.Part;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
@@ -107,8 +108,13 @@ class DefaultServerRequest implements ServerRequest {
|
||||
ServletRequestPathUtils.parseAndCache(servletRequest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod method() {
|
||||
return HttpMethod.valueOf(servletRequest().getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return servletRequest().getMethod();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
|
||||
private final List<HttpMessageConverter<?>> messageConverters;
|
||||
|
||||
private String methodName;
|
||||
private HttpMethod method;
|
||||
|
||||
private URI uri;
|
||||
|
||||
@@ -90,7 +90,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
Assert.notNull(other, "ServerRequest must not be null");
|
||||
this.servletRequest = other.servletRequest();
|
||||
this.messageConverters = new ArrayList<>(other.messageConverters());
|
||||
this.methodName = other.methodName();
|
||||
this.method = other.method();
|
||||
this.uri = other.uri();
|
||||
headers(headers -> headers.addAll(other.headers().asHttpHeaders()));
|
||||
cookies(cookies -> cookies.addAll(other.cookies()));
|
||||
@@ -102,7 +102,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
@Override
|
||||
public ServerRequest.Builder method(HttpMethod method) {
|
||||
Assert.notNull(method, "HttpMethod must not be null");
|
||||
this.methodName = method.name();
|
||||
this.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -188,14 +188,14 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
|
||||
@Override
|
||||
public ServerRequest build() {
|
||||
return new BuiltServerRequest(this.servletRequest, this.methodName, this.uri, this.headers, this.cookies,
|
||||
return new BuiltServerRequest(this.servletRequest, this.method, this.uri, this.headers, this.cookies,
|
||||
this.attributes, this.params, this.remoteAddress, this.body, this.messageConverters);
|
||||
}
|
||||
|
||||
|
||||
private static class BuiltServerRequest implements ServerRequest {
|
||||
|
||||
private final String methodName;
|
||||
private final HttpMethod method;
|
||||
|
||||
private final URI uri;
|
||||
|
||||
@@ -216,13 +216,13 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
@Nullable
|
||||
private final InetSocketAddress remoteAddress;
|
||||
|
||||
public BuiltServerRequest(HttpServletRequest servletRequest, String methodName, URI uri,
|
||||
public BuiltServerRequest(HttpServletRequest servletRequest, HttpMethod method, URI uri,
|
||||
HttpHeaders headers, MultiValueMap<String, Cookie> cookies,
|
||||
Map<String, Object> attributes, MultiValueMap<String, String> params,
|
||||
@Nullable InetSocketAddress remoteAddress, byte[] body, List<HttpMessageConverter<?>> messageConverters) {
|
||||
|
||||
this.servletRequest = servletRequest;
|
||||
this.methodName = methodName;
|
||||
this.method = method;
|
||||
this.uri = uri;
|
||||
this.headers = new HttpHeaders(headers);
|
||||
this.cookies = new LinkedMultiValueMap<>(cookies);
|
||||
@@ -234,8 +234,14 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod method() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return this.methodName;
|
||||
return this.method.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.security.Principal;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -435,12 +435,12 @@ public abstract class RequestPredicates {
|
||||
|
||||
public HttpMethodPredicate(HttpMethod httpMethod) {
|
||||
Assert.notNull(httpMethod, "HttpMethod must not be null");
|
||||
this.httpMethods = EnumSet.of(httpMethod);
|
||||
this.httpMethods = Set.of(httpMethod);
|
||||
}
|
||||
|
||||
public HttpMethodPredicate(HttpMethod... httpMethods) {
|
||||
Assert.notEmpty(httpMethods, "HttpMethods must not be empty");
|
||||
this.httpMethods = EnumSet.copyOf(Arrays.asList(httpMethods));
|
||||
this.httpMethods = new LinkedHashSet<>(Arrays.asList(httpMethods));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -451,16 +451,15 @@ public abstract class RequestPredicates {
|
||||
return match;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static HttpMethod method(ServerRequest request) {
|
||||
if (CorsUtils.isPreFlightRequest(request.servletRequest())) {
|
||||
String accessControlRequestMethod =
|
||||
request.headers().firstHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD);
|
||||
return HttpMethod.resolve(accessControlRequestMethod);
|
||||
}
|
||||
else {
|
||||
return request.method();
|
||||
if (accessControlRequestMethod != null) {
|
||||
return HttpMethod.valueOf(accessControlRequestMethod);
|
||||
}
|
||||
}
|
||||
return request.method();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -966,6 +965,7 @@ public abstract class RequestPredicates {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String methodName() {
|
||||
return this.request.methodName();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -39,7 +38,7 @@ import org.springframework.lang.Nullable;
|
||||
class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
|
||||
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS =
|
||||
EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS);
|
||||
Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS);
|
||||
|
||||
|
||||
private final Resource resource;
|
||||
@@ -53,17 +52,16 @@ class ResourceHandlerFunction implements HandlerFunction<ServerResponse> {
|
||||
@Override
|
||||
public ServerResponse handle(ServerRequest request) {
|
||||
HttpMethod method = request.method();
|
||||
if (method != null) {
|
||||
switch (method) {
|
||||
case GET:
|
||||
return EntityResponse.fromObject(this.resource).build();
|
||||
case HEAD:
|
||||
Resource headResource = new HeadMethodResource(this.resource);
|
||||
return EntityResponse.fromObject(headResource).build();
|
||||
case OPTIONS:
|
||||
return ServerResponse.ok()
|
||||
.allow(SUPPORTED_METHODS).build();
|
||||
}
|
||||
if (HttpMethod.GET.equals(method)) {
|
||||
return EntityResponse.fromObject(this.resource).build();
|
||||
}
|
||||
else if (HttpMethod.HEAD.equals(method)) {
|
||||
Resource headResource = new HeadMethodResource(this.resource);
|
||||
return EntityResponse.fromObject(headResource).build();
|
||||
}
|
||||
else if (HttpMethod.OPTIONS.equals(method)) {
|
||||
return ServerResponse.ok()
|
||||
.allow(SUPPORTED_METHODS).build();
|
||||
}
|
||||
return ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.allow(SUPPORTED_METHODS).build();
|
||||
|
||||
@@ -66,15 +66,14 @@ public interface ServerRequest {
|
||||
* @return the HTTP method as an HttpMethod enum value, or {@code null}
|
||||
* if not resolvable (e.g. in case of a non-standard HTTP method)
|
||||
*/
|
||||
@Nullable
|
||||
default HttpMethod method() {
|
||||
return HttpMethod.resolve(methodName());
|
||||
}
|
||||
HttpMethod method();
|
||||
|
||||
/**
|
||||
* Get the name of the HTTP method.
|
||||
* @return the HTTP method as a String
|
||||
* @deprecated in favor of {@link #method()}
|
||||
*/
|
||||
@Deprecated
|
||||
String methodName();
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -68,8 +67,7 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
*/
|
||||
public abstract class AbstractMessageConverterMethodArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS =
|
||||
EnumSet.of(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH);
|
||||
private static final Set<HttpMethod> SUPPORTED_METHODS = Set.of(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH);
|
||||
|
||||
private static final Object NO_VALUE = new Object();
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
|
||||
return userPrincipal;
|
||||
}
|
||||
else if (HttpMethod.class == paramType) {
|
||||
return HttpMethod.resolve(request.getMethod());
|
||||
return HttpMethod.valueOf(request.getMethod());
|
||||
}
|
||||
else if (Locale.class == paramType) {
|
||||
return RequestContextUtils.getLocale(request);
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -89,7 +88,7 @@ public class DefaultEntityResponseBuilderTests {
|
||||
String body = "foo";
|
||||
EntityResponse<String> result =
|
||||
EntityResponse.fromObject(body).allow(HttpMethod.GET).build();
|
||||
Set<HttpMethod> expected = EnumSet.of(HttpMethod.GET);
|
||||
Set<HttpMethod> expected = Set.of(HttpMethod.GET);
|
||||
assertThat(result.headers().getAllow()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
@@ -156,7 +156,7 @@ public class DefaultServerResponseBuilderTests {
|
||||
@Test
|
||||
public void allow() {
|
||||
ServerResponse response = ServerResponse.ok().allow(HttpMethod.GET).build();
|
||||
assertThat(response.headers().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET));
|
||||
assertThat(response.headers().getAllow()).isEqualTo(Set.of(HttpMethod.GET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -35,6 +35,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
||||
import org.springframework.http.converter.ResourceRegionHttpMessageConverter;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
|
||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||
@@ -173,14 +174,16 @@ public class ResourceHandlerFunctionTests {
|
||||
|
||||
ServerResponse response = this.handlerFunction.handle(request);
|
||||
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.headers().getAllow()).isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
assertThat(response.headers().getAllow()).isEqualTo(Set.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
|
||||
MockHttpServletResponse servletResponse = new MockHttpServletResponse();
|
||||
ModelAndView mav = response.writeTo(servletRequest, servletResponse, this.context);
|
||||
assertThat(mav).isNull();
|
||||
|
||||
assertThat(servletResponse.getStatus()).isEqualTo(200);
|
||||
assertThat(servletResponse.getHeader("Allow")).isEqualTo("GET,HEAD,OPTIONS");
|
||||
String allowHeader = servletResponse.getHeader("Allow");
|
||||
String[] methods = StringUtils.tokenizeToStringArray(allowHeader, ",");
|
||||
assertThat(methods).containsExactlyInAnyOrder("GET","HEAD","OPTIONS");
|
||||
byte[] actualBytes = servletResponse.getContentAsByteArray();
|
||||
assertThat(actualBytes.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -102,7 +102,7 @@ public class ResponseEntityExceptionHandlerTests {
|
||||
Exception ex = new HttpRequestMethodNotSupportedException("GET", supported);
|
||||
|
||||
ResponseEntity<Object> responseEntity = testException(ex);
|
||||
assertThat(responseEntity.getHeaders().getAllow()).isEqualTo(EnumSet.of(HttpMethod.POST, HttpMethod.DELETE));
|
||||
assertThat(responseEntity.getHeaders().getAllow()).isEqualTo(Set.of(HttpMethod.POST, HttpMethod.DELETE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user