Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.function.client

pack-priv final Class DefaultClientRequestBuilder

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.client.ClientRequest.Builder
Imports
java.net.URI, java.util.Collections, .LinkedHashMap, .List, .Map, .Optional, java.util.function.Consumer, org.reactivestreams.Publisher, reactor.core.publisher.Mono, org.springframework.core.ParameterizedTypeReference, org.springframework.core.codec.Hints, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, org.springframework.http.client.reactive.ClientHttpRequest, org.springframework.http.codec.HttpMessageWriter, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .LinkedMultiValueMap, .MultiValueMap, .ObjectUtils, org.springframework.web.reactive.function.BodyInserter, .BodyInserters

Default implementation of ClientRequest.Builder.
Author
Arjen Poutsma
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private BodyInserter<?, ? super ClientHttpRequest>
private final MultiValueMap<String, String>
private final HttpHeaders
private Consumer<ClientHttpRequest>
private HttpMethod
private URI

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public ClientRequest.Builder
attribute(String
the name of the attribute to add
name
,
Object
the value of the attribute to add
value
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.attribute.

Set the attribute with the given name to the given value.

public ClientRequest.Builder
attributes(Consumer<Map<String, Object>>
a function that consumes the attributes
attributesConsumer
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.attributes.

Manipulate the request attributes with the given consumer.

public <S, P extends Publisher<S>> ClientRequest.Builder
body(P
the Publisher to write to the request
publisher
,
Class<S>
the class of elements contained in the publisher
elementClass
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given Publisher and return it.

public <S, P extends Publisher<S>> ClientRequest.Builder
body(P
the Publisher to write to the request
publisher
,
ParameterizedTypeReference<S>
a type reference describing the elements contained in the publisher
typeReference
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given Publisher and return it.

public ClientRequest.Builder
body(BodyInserter<?, ? super ClientHttpRequest>
the BodyInserter that writes to the request
inserter
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given BodyInserter.

public ClientRequest
public ClientRequest.Builder
cookies(Consumer<MultiValueMap<String, String>>
a function that consumes the cookies map
cookiesConsumer
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.cookies.

Manipulate this request's cookies with the given consumer.

public ClientRequest.Builder
header(String
the header name
headerName
,
String...
the header value(s)
headerValues
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.header.

Add the given header value(s) under the given name.

public ClientRequest.Builder
headers(Consumer<HttpHeaders>
a function that consumes the HttpHeaders
headersConsumer
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.headers.

Manipulate this request's headers with the given consumer.

public ClientRequest.Builder
httpRequest(Consumer<ClientHttpRequest>
a consumer to access the ClientHttpRequest with
requestConsumer
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.httpRequest.

Callback for access to the ClientHttpRequest that in turn provides access to the native request of the underlying HTTP library.

public ClientRequest.Builder
method(HttpMethod
the new method
method
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.method.

Set the method of the request.

public ClientRequest.Builder
url(URI
the new url
url
)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.url.

Set the url of the request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final Map<String, Object> attributes
bodyback to summary
private BodyInserter<?, ? super ClientHttpRequest> body
cookiesback to summary
private final MultiValueMap<String, String> cookies
headersback to summary
private final HttpHeaders headers
httpRequestConsumerback to summary
private Consumer<ClientHttpRequest> httpRequestConsumer
Annotations
@Nullable
methodback to summary
private HttpMethod method
urlback to summary
private URI url

Constructor Detail

DefaultClientRequestBuilderback to summary
public DefaultClientRequestBuilder(ClientRequest other)
DefaultClientRequestBuilderback to summary
public DefaultClientRequestBuilder(HttpMethod method, URI url)

Method Detail

attributeback to summary
public ClientRequest.Builder attribute(String name, Object value)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.attribute.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.attribute.

Set the attribute with the given name to the given value.

Parameters
name:String

the name of the attribute to add

value:Object

the value of the attribute to add

Returns:ClientRequest.Builder

this builder

Annotations
@Override
attributesback to summary
public ClientRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.attributes.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.attributes.

Manipulate the request attributes with the given consumer. The attributes provided to the consumer are "live", so that the consumer can be used to inspect attributes, remove attributes, or use any of the other map-provided methods.

Parameters
attributesConsumer:Consumer<Map<String, Object>>

a function that consumes the attributes

Returns:ClientRequest.Builder

this builder

Annotations
@Override
bodyback to summary
public <S, P extends Publisher<S>> ClientRequest.Builder body(P publisher, Class<S> elementClass)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given Publisher and return it.

Parameters
<S>
the type of the elements contained in the publisher
<P>
the type of the Publisher
publisher:P

the Publisher to write to the request

elementClass:Class<S>

the class of elements contained in the publisher

Returns:ClientRequest.Builder

the built request

Annotations
@Override
bodyback to summary
public <S, P extends Publisher<S>> ClientRequest.Builder body(P publisher, ParameterizedTypeReference<S> typeReference)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given Publisher and return it.

Parameters
<S>
the type of the elements contained in the publisher
<P>
the type of the Publisher
publisher:P

the Publisher to write to the request

typeReference:ParameterizedTypeReference<S>

a type reference describing the elements contained in the publisher

Returns:ClientRequest.Builder

the built request

Annotations
@Override
bodyback to summary
public ClientRequest.Builder body(BodyInserter<?, ? super ClientHttpRequest> inserter)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.body.

Set the body of the request to the given BodyInserter.

Parameters
inserter:BodyInserter<?, ? super ClientHttpRequest>

the BodyInserter that writes to the request

Returns:ClientRequest.Builder

this builder

Annotations
@Override
buildback to summary
public ClientRequest build()

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.build.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.build.

Build the request.

Annotations
@Override
cookiesback to summary
public ClientRequest.Builder cookies(Consumer<MultiValueMap<String, String>> cookiesConsumer)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.cookies.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.cookies.

Manipulate this request's cookies with the given consumer. The map provided to the consumer is "live", so that the consumer can be used to overwrite existing cookie values, remove cookies, or use any of the other MultiValueMap methods.

Parameters
cookiesConsumer:Consumer<MultiValueMap<String, String>>

a function that consumes the cookies map

Returns:ClientRequest.Builder

this builder

Annotations
@Override
headerback to summary
public ClientRequest.Builder header(String headerName, String... headerValues)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.header.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.header.

Add the given header value(s) under the given name.

Parameters
headerName:String

the header name

headerValues:String[]

the header value(s)

Returns:ClientRequest.Builder

this builder

Annotations
@Override
headersback to summary
public ClientRequest.Builder headers(Consumer<HttpHeaders> headersConsumer)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.headers.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.headers.

Manipulate this request's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.

Parameters
headersConsumer:Consumer<HttpHeaders>

a function that consumes the HttpHeaders

Returns:ClientRequest.Builder

this builder

Annotations
@Override
httpRequestback to summary
public ClientRequest.Builder httpRequest(Consumer<ClientHttpRequest> requestConsumer)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.httpRequest.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.httpRequest.

Callback for access to the ClientHttpRequest that in turn provides access to the native request of the underlying HTTP library. This could be useful for setting advanced, per-request options that exposed by the underlying library.

Parameters
requestConsumer:Consumer<ClientHttpRequest>

a consumer to access the ClientHttpRequest with

Returns:ClientRequest.Builder

this builder

Annotations
@Override
methodback to summary
public ClientRequest.Builder method(HttpMethod method)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.method.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.method.

Set the method of the request.

Parameters
method:HttpMethod

the new method

Returns:ClientRequest.Builder

this builder

Annotations
@Override
urlback to summary
public ClientRequest.Builder url(URI url)

Implements org.springframework.web.reactive.function.client.ClientRequest.Builder.url.

Doc from org.springframework.web.reactive.function.client.ClientRequest.Builder.url.

Set the url of the request.

Parameters
url:URI

the new url

Returns:ClientRequest.Builder

this builder

Annotations
@Override
org.springframework.web.reactive.function.client back to summary

private Class DefaultClientRequestBuilder.BodyInserterRequest

extends Object
implements ClientRequest
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.function.client.DefaultClientRequestBuilder.BodyInserterRequest
All Implemented Interfaces
org.springframework.web.reactive.function.client.ClientRequest

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private final BodyInserter<?, ? super ClientHttpRequest>
private final MultiValueMap<String, String>
private final HttpHeaders
private final Consumer<ClientHttpRequest>
private final String
private final HttpMethod
private final URI

Constructor Summary

AccessConstructor and Description
public
BodyInserterRequest(HttpMethod method, URI url, HttpHeaders headers, MultiValueMap<String, String> cookies, BodyInserter<?, ? super ClientHttpRequest> body, Map<String, Object> attributes, Consumer<ClientHttpRequest> httpRequestConsumer)

Method Summary

Modifier and TypeMethod and Description
public Map<String, Object>
public BodyInserter<?, ? super ClientHttpRequest>
body()

Implements org.springframework.web.reactive.function.client.ClientRequest.body.

Return the body inserter of this request.

public MultiValueMap<String, String>
public HttpHeaders
public Consumer<ClientHttpRequest>
public String
logPrefix()

Implements org.springframework.web.reactive.function.client.ClientRequest.logPrefix.

Return a log message prefix to use to correlate messages for this request.

public HttpMethod
public URI
public Mono<Void>
writeTo(ClientHttpRequest
the client http request to write to
request
,
ExchangeStrategies
the strategies to use when writing
strategies
)

Implements org.springframework.web.reactive.function.client.ClientRequest.writeTo.

Write this request to the given ClientHttpRequest.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final Map<String, Object> attributes
bodyback to summary
private final BodyInserter<?, ? super ClientHttpRequest> body
cookiesback to summary
private final MultiValueMap<String, String> cookies
headersback to summary
private final HttpHeaders headers
httpRequestConsumerback to summary
private final Consumer<ClientHttpRequest> httpRequestConsumer
Annotations
@Nullable
logPrefixback to summary
private final String logPrefix
methodback to summary
private final HttpMethod method
urlback to summary
private final URI url

Constructor Detail

BodyInserterRequestback to summary
public BodyInserterRequest(HttpMethod method, URI url, HttpHeaders headers, MultiValueMap<String, String> cookies, BodyInserter<?, ? super ClientHttpRequest> body, Map<String, Object> attributes, Consumer<ClientHttpRequest> httpRequestConsumer)

Method Detail

attributesback to summary
public Map<String, Object> attributes()

Implements org.springframework.web.reactive.function.client.ClientRequest.attributes.

Doc from org.springframework.web.reactive.function.client.ClientRequest.attributes.

Return the attributes of this request.

Annotations
@Override
bodyback to summary
public BodyInserter<?, ? super ClientHttpRequest> body()

Implements org.springframework.web.reactive.function.client.ClientRequest.body.

Doc from org.springframework.web.reactive.function.client.ClientRequest.body.

Return the body inserter of this request.

Annotations
@Override
cookiesback to summary
public MultiValueMap<String, String> cookies()

Implements org.springframework.web.reactive.function.client.ClientRequest.cookies.

Doc from org.springframework.web.reactive.function.client.ClientRequest.cookies.

Return the cookies of this request.

Annotations
@Override
headersback to summary
public HttpHeaders headers()

Implements org.springframework.web.reactive.function.client.ClientRequest.headers.

Doc from org.springframework.web.reactive.function.client.ClientRequest.headers.

Return the headers of this request.

Annotations
@Override
httpRequestback to summary
public Consumer<ClientHttpRequest> httpRequest()

Implements org.springframework.web.reactive.function.client.ClientRequest.httpRequest.

Doc from org.springframework.web.reactive.function.client.ClientRequest.httpRequest.

Return consumer(s) configured to access to the ClientHttpRequest.

Annotations
@Override
logPrefixback to summary
public String logPrefix()

Implements org.springframework.web.reactive.function.client.ClientRequest.logPrefix.

Doc from org.springframework.web.reactive.function.client.ClientRequest.logPrefix.

Return a log message prefix to use to correlate messages for this request. The prefix is based on the value of the attribute LOG_ID_ATTRIBUTE surrounded with "[" and "]".

Returns:String

the log message prefix or an empty String if the LOG_ID_ATTRIBUTE is not set.

Annotations
@Override
methodback to summary
public HttpMethod method()

Implements org.springframework.web.reactive.function.client.ClientRequest.method.

Doc from org.springframework.web.reactive.function.client.ClientRequest.method.

Return the HTTP method.

Annotations
@Override
urlback to summary
public URI url()

Implements org.springframework.web.reactive.function.client.ClientRequest.url.

Doc from org.springframework.web.reactive.function.client.ClientRequest.url.

Return the request URI.

Annotations
@Override
writeToback to summary
public Mono<Void> writeTo(ClientHttpRequest request, ExchangeStrategies strategies)

Implements org.springframework.web.reactive.function.client.ClientRequest.writeTo.

Doc from org.springframework.web.reactive.function.client.ClientRequest.writeTo.

Write this request to the given ClientHttpRequest.

Parameters
request:ClientHttpRequest

the client http request to write to

strategies:ExchangeStrategies

the strategies to use when writing

Returns:Mono<Void>

Mono<Void> to indicate when writing is complete

Annotations
@Override