Add HttpRequest.getMethodValue

This commit introduces a new method in HttpRequest:
`String getMethodValue`, which returns the HTTP method as a String.
Furthermore, HttpRequest.getMethod() has been given a default
implementation using this String value in combination with
`HttpMethod.resolve`.

Issue: SPR-15545
This commit is contained in:
Arjen Poutsma
2017-05-24 16:36:58 +02:00
parent 31d1e26c95
commit 630fc194f0
26 changed files with 111 additions and 42 deletions

View File

@@ -267,6 +267,11 @@ public class InterceptingClientHttpRequestFactoryTests {
return method;
}
@Override
public String getMethodValue() {
return method.name();
}
public void setMethod(HttpMethod method) {
this.method = method;
}

View File

@@ -31,7 +31,6 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -93,8 +92,8 @@ public class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
}
@Override
public HttpMethod getMethod() {
return HttpMethod.valueOf(this.request.getHttpMethod().name());
public String getMethodValue() {
return this.request.getHttpMethod().name();
}
@Override

View File

@@ -82,6 +82,11 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
return this.httpMethod;
}
@Override
public String getMethodValue() {
return this.httpMethod.name();
}
@Override
public String getContextPath() {
return this.contextPath;