diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java index dcb48225ae5..0c614524b0f 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +66,11 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie return this.httpMethod; } + @Override + public String getMethodValue() { + return this.httpMethod.name(); + } + public void setURI(URI uri) { this.uri = uri; } diff --git a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java index e956c438fc3..3c50f25f101 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java @@ -83,6 +83,11 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest { return this.httpMethod; } + @Override + public String getMethodValue() { + return this.httpMethod.name(); + } + @Override public String getContextPath() { return this.contextPath; diff --git a/spring-web/src/main/java/org/springframework/http/HttpRequest.java b/spring-web/src/main/java/org/springframework/http/HttpRequest.java index 2f670a37e7e..ad5bc9b7332 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/HttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,15 @@ public interface HttpRequest extends HttpMessage { * @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) */ - HttpMethod getMethod(); + default HttpMethod getMethod() { + return HttpMethod.resolve(getMethodValue()); + } + + /** + * Return the HTTP method of the request as a String + * @return the HTTP method as a String + */ + String getMethodValue(); /** * Return the URI of the request. diff --git a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java index 1de5a5e4875..62a85c058db 100644 --- a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java +++ b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,11 @@ final class BufferingClientHttpRequestWrapper extends AbstractBufferingClientHtt return this.request.getMethod(); } + @Override + public String getMethodValue() { + return this.request.getMethodValue(); + } + @Override public URI getURI() { return this.request.getURI(); diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java index 1a41f63b159..1e3a7c41124 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java @@ -30,7 +30,6 @@ import org.apache.http.nio.entity.NByteArrayEntity; import org.apache.http.protocol.HttpContext; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.util.concurrent.FailureCallback; import org.springframework.util.concurrent.FutureAdapter; import org.springframework.util.concurrent.ListenableFuture; @@ -69,8 +68,8 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.httpRequest.getMethod()); + public String getMethodValue() { + return this.httpRequest.getMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java index d9875264c84..a605a67683b 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,8 +63,8 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.httpRequest.getMethod()); + public String getMethodValue() { + return this.httpRequest.getMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsStreamingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsStreamingClientHttpRequest.java index e27d9f8f0d5..0afa8ed0083 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsStreamingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsStreamingClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,6 @@ 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; @@ -65,8 +64,8 @@ final class HttpComponentsStreamingClientHttpRequest extends AbstractClientHttpR @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.httpRequest.getMethod()); + public String getMethodValue() { + return this.httpRequest.getMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequest.java index e58b3ef06c3..0d8d817ea8d 100644 --- a/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequest.java @@ -75,7 +75,12 @@ class InterceptingAsyncClientHttpRequest extends AbstractBufferingAsyncClientHtt @Override public HttpMethod getMethod() { - return httpMethod; + return this.httpMethod; + } + + @Override + public String getMethodValue() { + return this.httpMethod.name(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java index abf78a6b9b9..d2f49b91e4c 100644 --- a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java @@ -59,6 +59,11 @@ class InterceptingClientHttpRequest extends AbstractBufferingClientHttpRequest { return this.method; } + @Override + public String getMethodValue() { + return this.method.name(); + } + @Override public URI getURI() { return this.uri; diff --git a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java index d48f5ddd47c..8af1a2145b2 100644 --- a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java @@ -77,6 +77,11 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements return this.method; } + @Override + public String getMethodValue() { + return this.method.name(); + } + @Override public URI getURI() { return this.uri; diff --git a/spring-web/src/main/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequest.java index 7333d8bc368..8a9cedbea76 100644 --- a/spring-web/src/main/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequest.java @@ -63,6 +63,11 @@ class OkHttp3AsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequ return this.method; } + @Override + public String getMethodValue() { + return this.method.name(); + } + @Override public URI getURI() { return this.uri; diff --git a/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequest.java index aa1416f87b6..a8b44e602ba 100644 --- a/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,11 @@ class OkHttp3ClientHttpRequest extends AbstractBufferingClientHttpRequest { return this.method; } + @Override + public String getMethodValue() { + return this.method.name(); + } + @Override public URI getURI() { return this.uri; diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingAsyncClientHttpRequest.java index e98a7a2d755..26787851611 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingAsyncClientHttpRequest.java @@ -58,8 +58,8 @@ final class SimpleBufferingAsyncClientHttpRequest extends AbstractBufferingAsync @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.connection.getRequestMethod()); + public String getMethodValue() { + return this.connection.getRequestMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java index 9a992f332df..a5ec316225f 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,8 +51,8 @@ final class SimpleBufferingClientHttpRequest extends AbstractBufferingClientHttp @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.connection.getRequestMethod()); + public String getMethodValue() { + return this.connection.getRequestMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java index f79f2cbbd58..cfb43386664 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java @@ -25,7 +25,6 @@ import java.util.concurrent.Callable; import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.util.StreamUtils; import org.springframework.util.concurrent.ListenableFuture; @@ -64,8 +63,8 @@ final class SimpleStreamingAsyncClientHttpRequest extends AbstractAsyncClientHtt @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.connection.getRequestMethod()); + public String getMethodValue() { + return this.connection.getRequestMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java index 98ca2902e08..47acd49a258 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,8 +52,9 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest { } - public HttpMethod getMethod() { - return HttpMethod.resolve(this.connection.getRequestMethod()); + @Override + public String getMethodValue() { + return this.connection.getRequestMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java b/spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java index c17f3671d1c..e46e7456e16 100644 --- a/spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java +++ b/spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,14 @@ public class HttpRequestWrapper implements HttpRequest { return this.request.getMethod(); } + /** + * Return the method value of the wrapped request. + */ + @Override + public String getMethodValue() { + return this.request.getMethodValue(); + } + /** * Return the URI of the wrapped request. */ diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java index 26cdc9f37e4..b2df7e93745 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java @@ -83,8 +83,8 @@ public class ServletServerHttpRequest implements ServerHttpRequest { } @Override - public HttpMethod getMethod() { - return HttpMethod.resolve(this.servletRequest.getMethod()); + public String getMethodValue() { + return this.servletRequest.getMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java index c2dad3f1564..5c73b2db4ee 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java @@ -28,7 +28,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; @@ -82,8 +81,8 @@ public class ReactorServerHttpRequest extends AbstractServerHttpRequest { } @Override - public HttpMethod getMethod() { - return HttpMethod.valueOf(this.request.method().name()); + public String getMethodValue() { + return this.request.method().name(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java index 9eae1805256..422c9eb35fc 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java @@ -58,6 +58,11 @@ public class ServerHttpRequestDecorator implements ServerHttpRequest { return getDelegate().getMethod(); } + @Override + public String getMethodValue() { + return getDelegate().getMethodValue(); + } + @Override public URI getURI() { return getDelegate().getURI(); diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java index eafbbbfb966..08c51b62a6b 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java @@ -39,7 +39,6 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.http.HttpCookie; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.util.LinkedCaseInsensitiveMap; @@ -150,8 +149,8 @@ public class ServletServerHttpRequest extends AbstractServerHttpRequest { } @Override - public HttpMethod getMethod() { - return HttpMethod.valueOf(getServletRequest().getMethod()); + public String getMethodValue() { + return getServletRequest().getMethod(); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java index 98eb90d4ec9..f66b9ccbdcf 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java @@ -34,7 +34,6 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferFactory; 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; @@ -83,8 +82,8 @@ public class UndertowServerHttpRequest extends AbstractServerHttpRequest { } @Override - public HttpMethod getMethod() { - return HttpMethod.valueOf(this.getUndertowExchange().getRequestMethod().toString()); + public String getMethodValue() { + return this.getUndertowExchange().getRequestMethod().toString(); } @Override diff --git a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java index 212e0239817..a45dd65237b 100644 --- a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java @@ -662,6 +662,10 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I return request.getMethod(); } @Override + public String getMethodValue() { + return request.getMethodValue(); + } + @Override public URI getURI() { return request.getURI(); } diff --git a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java index b594b5db78c..6b4caeb3081 100644 --- a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java @@ -267,6 +267,11 @@ public class InterceptingClientHttpRequestFactoryTests { return method; } + @Override + public String getMethodValue() { + return method.name(); + } + public void setMethod(HttpMethod method) { this.method = method; } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java b/spring-web/src/test/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java index d10e0004d17..ee528e1dc3a 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java @@ -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 diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java index 8d2504900b1..d6543032cd0 100644 --- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java +++ b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java @@ -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;