Interface ClientRequest
public interface ClientRequest
Represents a typed, immutable, client-side HTTP request, as executed by theExchangeFunction
. Instances of this interface can be created via static builder methods.Note that applications are more likely to perform requests through
WebClient
rather than using this directly.- Since:
- 5.0
- Author:
- Brian Clozel, Arjen Poutsma
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ClientRequest.Builder
Defines a builder for a request.
Field Summary
Fields Modifier and Type Field Description static String
LOG_ID_ATTRIBUTE
Name ofattribute
whose value can be used to correlate log messages for this request.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default Optional<Object>
attribute(String name)
Return the request attribute value if present.Map<String,Object>
attributes()
Return the attributes of this request.BodyInserter<?,? super ClientHttpRequest>
body()
Return the body inserter of this request.MultiValueMap<String,String>
cookies()
Return the cookies of this request.static ClientRequest.Builder
create(HttpMethod method, URI url)
Create a request builder with the given method and url.static ClientRequest.Builder
from(ClientRequest other)
Create a builder with the method, URI, headers, and cookies of the given request.HttpHeaders
headers()
Return the headers of this request.String
logPrefix()
Return a log message prefix to use to correlate messages for this request.HttpMethod
method()
Return the HTTP method.static ClientRequest.Builder
method(HttpMethod method, URI url)
Deprecated.in favor ofcreate(HttpMethod, URI)
URI
url()
Return the request URI.reactor.core.publisher.Mono<Void>
writeTo(ClientHttpRequest request, ExchangeStrategies strategies)
Write this request to the givenClientHttpRequest
.
Field Detail
LOG_ID_ATTRIBUTE
static final String LOG_ID_ATTRIBUTE
Name ofattribute
whose value can be used to correlate log messages for this request. UselogPrefix()
to obtain a consistently formatted prefix based on this attribute.- Since:
- 5.1
- See Also:
logPrefix()
Method Detail
method
HttpMethod method()
Return the HTTP method.
headers
HttpHeaders headers()
Return the headers of this request.
cookies
MultiValueMap<String,String> cookies()
Return the cookies of this request.
body
BodyInserter<?,? super ClientHttpRequest> body()
Return the body inserter of this request.
attribute
default Optional<Object> attribute(String name)
Return the request attribute value if present.- Parameters:
name
- the attribute name- Returns:
- the attribute value
attributes
Map<String,Object> attributes()
Return the attributes of this request.
logPrefix
String logPrefix()
Return a log message prefix to use to correlate messages for this request. The prefix is based on the value of the attributeLOG_ID_ATTRIBUTE
surrounded with "[" and "]".- Returns:
- the log message prefix or an empty String if the
LOG_ID_ATTRIBUTE
is not set. - Since:
- 5.1
writeTo
reactor.core.publisher.Mono<Void> writeTo(ClientHttpRequest request, ExchangeStrategies strategies)
Write this request to the givenClientHttpRequest
.- Parameters:
request
- the client http request to write tostrategies
- the strategies to use when writing- Returns:
Mono<Void>
to indicate when writing is complete
from
static ClientRequest.Builder from(ClientRequest other)
Create a builder with the method, URI, headers, and cookies of the given request.- Parameters:
other
- the request to copy the method, URI, headers, and cookies from- Returns:
- the created builder
method
@Deprecated static ClientRequest.Builder method(HttpMethod method, URI url)
Deprecated.in favor ofcreate(HttpMethod, URI)
Create a builder with the given method and url.- Parameters:
method
- the HTTP method (GET, POST, etc)url
- the url (as a URI instance)- Returns:
- the created builder
create
static ClientRequest.Builder create(HttpMethod method, URI url)
Create a request builder with the given method and url.- Parameters:
method
- the HTTP method (GET, POST, etc)url
- the url (as a URI instance)- Returns:
- the created builder