接口 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.- 从以下版本开始:
- 5.0
- 作者:
- Brian Clozel, Arjen Poutsma
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static interface
ClientRequest.Builder
Defines a builder for a request.
字段概要
字段 修饰符和类型 字段 说明 static String
LOG_ID_ATTRIBUTE
Name ofattribute
whose value can be used to correlate log messages for this request.
方法概要
所有方法 静态方法 实例方法 抽象方法 默认方法 已过时的方法 修饰符和类型 方法 说明 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)
已过时。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
.
字段详细资料
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.- 从以下版本开始:
- 5.1
- 另请参阅:
logPrefix()
方法详细资料
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.- 参数:
name
- the attribute name- 返回:
- 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 "]".- 返回:
- the log message prefix or an empty String if the
LOG_ID_ATTRIBUTE
is not set. - 从以下版本开始:
- 5.1
writeTo
reactor.core.publisher.Mono<Void> writeTo(ClientHttpRequest request, ExchangeStrategies strategies)
Write this request to the givenClientHttpRequest
.- 参数:
request
- the client http request to write tostrategies
- the strategies to use when writing- 返回:
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.- 参数:
other
- the request to copy the method, URI, headers, and cookies from- 返回:
- the created builder
method
@Deprecated static ClientRequest.Builder method(HttpMethod method, URI url)
已过时。in favor ofcreate(HttpMethod, URI)
Create a builder with the given method and url.- 参数:
method
- the HTTP method (GET, POST, etc)url
- the url (as a URI instance)- 返回:
- the created builder
create
static ClientRequest.Builder create(HttpMethod method, URI url)
Create a request builder with the given method and url.- 参数:
method
- the HTTP method (GET, POST, etc)url
- the url (as a URI instance)- 返回:
- the created builder