Interface ClientRequest.Builder
- Enclosing interface:
- ClientRequest
public static interface ClientRequest.Builder
Defines a builder for a request.
-
Method Summary
Modifier and TypeMethodDescriptionSet the attribute with the given name to the given value.attributes
(Consumer<Map<String, Object>> attributesConsumer) Manipulate the request attributes with the given consumer.body
(BodyInserter<?, ? super ClientHttpRequest> inserter) Set the body of the request to the givenBodyInserter
.<S,
P extends Publisher<S>>
ClientRequest.BuilderSet the body of the request to the givenPublisher
and return it.<S,
P extends Publisher<S>>
ClientRequest.Builderbody
(P publisher, ParameterizedTypeReference<S> typeReference) Set the body of the request to the givenPublisher
and return it.build()
Build the request.Add a cookie with the given name and value(s).cookies
(Consumer<MultiValueMap<String, String>> cookiesConsumer) Manipulate this request's cookies with the given consumer.Add the given header value(s) under the given name.headers
(Consumer<HttpHeaders> headersConsumer) Manipulate this request's headers with the given consumer.httpRequest
(Consumer<ClientHttpRequest> requestConsumer) Callback for access to theClientHttpRequest
that in turn provides access to the native request of the underlying HTTP library.method
(HttpMethod method) Set the method of the request.Set the url of the request.
-
Method Details
-
method
Set the method of the request.- Parameters:
method
- the new method- Returns:
- this builder
- Since:
- 5.0.1
-
url
Set the url of the request.- Parameters:
url
- the new url- Returns:
- this builder
- Since:
- 5.0.1
-
header
Add the given header value(s) under the given name.- Parameters:
headerName
- the header nameheaderValues
- the header value(s)- Returns:
- this builder
- See Also:
-
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 otherHttpHeaders
methods.- Parameters:
headersConsumer
- a function that consumes theHttpHeaders
- Returns:
- this builder
-
cookie
Add a cookie with the given name and value(s).- Parameters:
name
- the cookie namevalues
- the cookie value(s)- Returns:
- this 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 otherMultiValueMap
methods.- Parameters:
cookiesConsumer
- a function that consumes the cookies map- Returns:
- this builder
-
body
Set the body of the request to the givenBodyInserter
.- Parameters:
inserter
- theBodyInserter
that writes to the request- Returns:
- this builder
-
body
Set the body of the request to the givenPublisher
and return it.- Type Parameters:
S
- the type of the elements contained in the publisherP
- the type of thePublisher
- Parameters:
publisher
- thePublisher
to write to the requestelementClass
- the class of elements contained in the publisher- Returns:
- the built request
-
body
<S,P extends Publisher<S>> ClientRequest.Builder body(P publisher, ParameterizedTypeReference<S> typeReference) Set the body of the request to the givenPublisher
and return it.- Type Parameters:
S
- the type of the elements contained in the publisherP
- the type of thePublisher
- Parameters:
publisher
- thePublisher
to write to the requesttypeReference
- a type reference describing the elements contained in the publisher- Returns:
- the built request
-
attribute
Set the attribute with the given name to the given value.- Parameters:
name
- the name of the attribute to addvalue
- the value of the attribute to add- Returns:
- this 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
- a function that consumes the attributes- Returns:
- this builder
-
httpRequest
Callback for access to theClientHttpRequest
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
- a consumer to access theClientHttpRequest
with- Returns:
- this builder
- Since:
- 5.3
-
build
ClientRequest build()Build the request.
-