接口 WebTestClient.RequestBodySpec
- 所有已知子接口:
WebTestClient.RequestBodyUriSpec
- 封闭接口:
- WebTestClient
public static interface WebTestClient.RequestBodySpec extends WebTestClient.RequestHeadersSpec<WebTestClient.RequestBodySpec>
Specification for providing body of a request.
方法概要
所有方法 实例方法 抽象方法 已过时的方法 修饰符和类型 方法 说明 WebTestClient.RequestHeadersSpec<?>
body(Object producer, Class<?> elementClass)
Set the body from the given producer.WebTestClient.RequestHeadersSpec<?>
body(Object producer, ParameterizedTypeReference<?> elementTypeRef)
Set the body from the given producer.WebTestClient.RequestHeadersSpec<?>
body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the givenBodyInserter
.<T,S extends org.reactivestreams.Publisher<T>>
WebTestClient.RequestHeadersSpec<?>body(S publisher, Class<T> elementClass)
Set the body from the givenPublisher
.<T,S extends org.reactivestreams.Publisher<T>>
WebTestClient.RequestHeadersSpec<?>body(S publisher, ParameterizedTypeReference<T> elementTypeRef)
Variant ofbody(Publisher, Class)
that allows providing element type information with generics.WebTestClient.RequestHeadersSpec<?>
bodyValue(Object body)
Set the body to the givenObject
value.WebTestClient.RequestBodySpec
contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.WebTestClient.RequestBodySpec
contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.WebTestClient.RequestHeadersSpec<?>
syncBody(Object body)
已过时。as of Spring Framework 5.2 in favor ofbodyValue(Object)
从接口继承的方法 org.springframework.test.web.reactive.server.WebTestClient.RequestHeadersSpec
accept, acceptCharset, attribute, attributes, cookie, cookies, exchange, header, headers, ifModifiedSince, ifNoneMatch
方法详细资料
contentLength
WebTestClient.RequestBodySpec contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.- 参数:
contentLength
- the content length- 返回:
- the same instance
- 另请参阅:
HttpHeaders.setContentLength(long)
contentType
WebTestClient.RequestBodySpec contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.- 参数:
contentType
- the content type- 返回:
- the same instance
- 另请参阅:
HttpHeaders.setContentType(MediaType)
bodyValue
WebTestClient.RequestHeadersSpec<?> bodyValue(Object body)
Set the body to the givenObject
value. This method invokes thebodyValue
method on the underlyingWebClient
.- 参数:
body
- the value to write to the request body- 返回:
- spec for further declaration of the request
- 从以下版本开始:
- 5.2
body
<T,S extends org.reactivestreams.Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, Class<T> elementClass)
- 类型参数:
T
- the type of the elements contained in the publisherS
- the type of thePublisher
- 参数:
publisher
- the request body dataelementClass
- the class of elements contained in the publisher- 返回:
- spec for further declaration of the request
body
<T,S extends org.reactivestreams.Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, ParameterizedTypeReference<T> elementTypeRef)
Variant ofbody(Publisher, Class)
that allows providing element type information with generics.- 类型参数:
T
- the type of the elements contained in the publisherS
- the type of thePublisher
- 参数:
publisher
- the request body dataelementTypeRef
- the type reference of elements contained in the publisher- 返回:
- spec for further declaration of the request
- 从以下版本开始:
- 5.2
body
WebTestClient.RequestHeadersSpec<?> body(Object producer, Class<?> elementClass)
Set the body from the given producer. This method invokes thebody(Object, Class)
method on the underlyingWebClient
.- 参数:
producer
- the producer to write to the request. This must be aPublisher
or another producer adaptable to aPublisher
viaReactiveAdapterRegistry
elementClass
- the class of elements contained in the producer- 返回:
- spec for further declaration of the request
- 从以下版本开始:
- 5.2
body
WebTestClient.RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef)
Set the body from the given producer. This method invokes thebody(Object, ParameterizedTypeReference)
method on the underlyingWebClient
.- 参数:
producer
- the producer to write to the request. This must be aPublisher
or another producer adaptable to aPublisher
viaReactiveAdapterRegistry
elementTypeRef
- the type reference of elements contained in the producer- 返回:
- spec for further declaration of the request
- 从以下版本开始:
- 5.2
body
WebTestClient.RequestHeadersSpec<?> body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the givenBodyInserter
. This method invokes thebody(BodyInserter)
method on the underlyingWebClient
.- 参数:
inserter
- the body inserter to use- 返回:
- spec for further declaration of the request
- 另请参阅:
BodyInserters
syncBody
@Deprecated WebTestClient.RequestHeadersSpec<?> syncBody(Object body)
已过时。as of Spring Framework 5.2 in favor ofbodyValue(Object)
Shortcut forbody(BodyInserter)
with a value inserter. As of 5.2 this method delegates tobodyValue(Object)
.