接口 ClientRequest.Builder
- 封闭接口:
- ClientRequest
public static interface ClientRequest.Builder
Defines a builder for a request.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 ClientRequest.Builder
attribute(String name, Object value)
Set the attribute with the given name to the given value.ClientRequest.Builder
attributes(Consumer<Map<String,Object>> attributesConsumer)
Manipulate the request attributes with the given consumer.ClientRequest.Builder
body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the givenBodyInserter
.<S,P extends org.reactivestreams.Publisher<S>>
ClientRequest.Builderbody(P publisher, Class<S> elementClass)
Set the body of the request to the givenPublisher
and return it.<S,P extends org.reactivestreams.Publisher<S>>
ClientRequest.Builderbody(P publisher, ParameterizedTypeReference<S> typeReference)
Set the body of the request to the givenPublisher
and return it.ClientRequest
build()
Build the request.ClientRequest.Builder
cookie(String name, String... values)
Add a cookie with the given name and value(s).ClientRequest.Builder
cookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
Manipulate this request's cookies with the given consumer.ClientRequest.Builder
header(String headerName, String... headerValues)
Add the given header value(s) under the given name.ClientRequest.Builder
headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this request's headers with the given consumer.ClientRequest.Builder
method(HttpMethod method)
Set the method of the request.ClientRequest.Builder
url(URI url)
Set the url of the request.
方法详细资料
method
ClientRequest.Builder method(HttpMethod method)
Set the method of the request.- 参数:
method
- the new method- 返回:
- this builder
- 从以下版本开始:
- 5.0.1
url
ClientRequest.Builder url(URI url)
Set the url of the request.- 参数:
url
- the new url- 返回:
- this builder
- 从以下版本开始:
- 5.0.1
header
ClientRequest.Builder header(String headerName, String... headerValues)
Add the given header value(s) under the given name.- 参数:
headerName
- the header nameheaderValues
- the header value(s)- 返回:
- this builder
- 另请参阅:
HttpHeaders.add(String, String)
headers
ClientRequest.Builder headers(Consumer<HttpHeaders> headersConsumer)
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.- 参数:
headersConsumer
- a function that consumes theHttpHeaders
- 返回:
- this builder
cookie
ClientRequest.Builder cookie(String name, String... values)
Add a cookie with the given name and value(s).- 参数:
name
- the cookie namevalues
- the cookie value(s)- 返回:
- this builder
cookies
ClientRequest.Builder cookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
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 header values, remove values, or use any of the otherMultiValueMap
methods.- 参数:
cookiesConsumer
- a function that consumes the cookies map- 返回:
- this builder
body
ClientRequest.Builder body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the givenBodyInserter
.- 参数:
inserter
- theBodyInserter
that writes to the request- 返回:
- this builder
body
<S,P extends org.reactivestreams.Publisher<S>> ClientRequest.Builder body(P publisher, Class<S> elementClass)
Set the body of the request to the givenPublisher
and return it.- 类型参数:
S
- the type of the elements contained in the publisherP
- the type of thePublisher
- 参数:
publisher
- thePublisher
to write to the requestelementClass
- the class of elements contained in the publisher- 返回:
- the built request
body
<S,P extends org.reactivestreams.Publisher<S>> ClientRequest.Builder body(P publisher, ParameterizedTypeReference<S> typeReference)
Set the body of the request to the givenPublisher
and return it.- 类型参数:
S
- the type of the elements contained in the publisherP
- the type of thePublisher
- 参数:
publisher
- thePublisher
to write to the requesttypeReference
- a type reference describing the elements contained in the publisher- 返回:
- the built request
attribute
ClientRequest.Builder attribute(String name, Object value)
Set the attribute with the given name to the given value.- 参数:
name
- the name of the attribute to addvalue
- the value of the attribute to add- 返回:
- this builder
attributes
ClientRequest.Builder attributes(Consumer<Map<String,Object>> attributesConsumer)
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.- 参数:
attributesConsumer
- a function that consumes the attributes- 返回:
- this builder
build
ClientRequest build()
Build the request.