Class HttpRequestWrapper
- java.lang.Object
- org.springframework.http.client.support.HttpRequestWrapper
- All Implemented Interfaces:
HttpMessage
,HttpRequest
public class HttpRequestWrapper extends Object implements HttpRequest
Provides a convenient implementation of theHttpRequest
interface that can be overridden to adapt the request.These methods default to calling through to the wrapped request object.
- Since:
- 3.1
- Author:
- Arjen Poutsma
Constructor Summary
Constructors Constructor Description HttpRequestWrapper(HttpRequest request)
Create a newHttpRequest
wrapping the given request object.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpHeaders
getHeaders()
Return the headers of the wrapped request.HttpMethod
getMethod()
Return the method of the wrapped request.String
getMethodValue()
Return the method value of the wrapped request.HttpRequest
getRequest()
Return the wrapped request.URI
getURI()
Return the URI of the wrapped request.
Constructor Detail
HttpRequestWrapper
public HttpRequestWrapper(HttpRequest request)
Create a newHttpRequest
wrapping the given request object.- Parameters:
request
- the request object to be wrapped
Method Detail
getRequest
public HttpRequest getRequest()
Return the wrapped request.
getMethod
@Nullable public HttpMethod getMethod()
Return the method of the wrapped request.- Specified by:
getMethod
in interfaceHttpRequest
- Returns:
- the HTTP method as an HttpMethod enum value, or
null
if not resolvable (e.g. in case of a non-standard HTTP method) - See Also:
HttpRequest.getMethodValue()
,HttpMethod.resolve(String)
getMethodValue
public String getMethodValue()
Return the method value of the wrapped request.- Specified by:
getMethodValue
in interfaceHttpRequest
- Returns:
- the HTTP method as a plain String
- See Also:
HttpRequest.getMethod()
getURI
public URI getURI()
Return the URI of the wrapped request.- Specified by:
getURI
in interfaceHttpRequest
- Returns:
- the URI of the request (never
null
)
getHeaders
public HttpHeaders getHeaders()
Return the headers of the wrapped request.- Specified by:
getHeaders
in interfaceHttpMessage
- Returns:
- a corresponding HttpHeaders object (never
null
)