public static interface WebTestClient.RequestBodySpec extends WebTestClient.RequestHeadersSpec<WebTestClient.RequestBodySpec>
| Modifier and Type | Method and Description |
|---|---|
WebTestClient.RequestHeadersSpec<?> |
body(org.springframework.web.reactive.function.BodyInserter<?,? super org.springframework.http.client.reactive.ClientHttpRequest> inserter)
Set the body of the request to the given
BodyInserter. |
WebTestClient.RequestHeadersSpec<?> |
body(Object body)
Set the body of the request to the given
Object and perform the request. |
WebTestClient.RequestHeadersSpec<?> |
body(Object producer,
Class<?> elementClass)
Set the body of the request to the given producer.
|
WebTestClient.RequestHeadersSpec<?> |
body(Object producer,
org.springframework.core.ParameterizedTypeReference<?> elementTypeRef)
Set the body of the request to the given producer.
|
<T,S extends org.reactivestreams.Publisher<T>> |
body(S publisher,
Class<T> elementClass)
Set the body of the request to the given asynchronous
Publisher. |
<T,S extends org.reactivestreams.Publisher<T>> |
body(S publisher,
org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)
Set the body of the request to the given asynchronous
Publisher. |
WebTestClient.RequestBodySpec |
contentLength(long contentLength)
Set the length of the body in bytes, as specified by the
Content-Length header. |
WebTestClient.RequestBodySpec |
contentType(org.springframework.http.MediaType contentType)
Set the media type of the body, as specified
by the
Content-Type header. |
WebTestClient.RequestHeadersSpec<?> |
syncBody(Object body)
Deprecated.
as of Spring Framework 5.2 in favor of
body(Object) |
accept, acceptCharset, attribute, attributes, cookie, cookies, exchange, header, headers, ifModifiedSince, ifNoneMatchWebTestClient.RequestBodySpec contentLength(long contentLength)
Content-Length header.contentLength - the content lengthHttpHeaders.setContentLength(long)WebTestClient.RequestBodySpec contentType(org.springframework.http.MediaType contentType)
Content-Type header.contentType - the content typeHttpHeaders.setContentType(MediaType)WebTestClient.RequestHeadersSpec<?> body(Object body)
Object and perform the request.
This method is a convenient shortcut for:
.body(BodyInserters.fromObject(object))
The body can be a
MultiValueMap to create
a multipart request. The values in the MultiValueMap can be
any Object representing the body of the part, or an
HttpEntity representing a
part with body and headers. The MultiValueMap can be built
conveniently using
body - the Object to write to the requestWebTestClient.RequestHeadersSpec<?> body(Object producer, Class<?> elementClass)
producer - the producer to write to the request. This must be a
Publisher or another producer adaptable to a
Publisher via ReactiveAdapterRegistryelementClass - the class of elements contained in the producerWebTestClient.RequestHeadersSpec<?> body(Object producer, org.springframework.core.ParameterizedTypeReference<?> elementTypeRef)
producer - the producer to write to the request. This must be a
Publisher or another producer adaptable to a
Publisher via ReactiveAdapterRegistryelementTypeRef - the type reference of elements contained in the producer<T,S extends org.reactivestreams.Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, Class<T> elementClass)
Publisher.T - the type of the elements contained in the publisherS - the type of the Publisherpublisher - the request body dataelementClass - the class of elements contained in the publisher<T,S extends org.reactivestreams.Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)
Publisher.T - the type of the elements contained in the publisherS - the type of the Publisherpublisher - the request body dataelementTypeRef - the type reference of elements contained in the publisherWebTestClient.RequestHeadersSpec<?> body(org.springframework.web.reactive.function.BodyInserter<?,? super org.springframework.http.client.reactive.ClientHttpRequest> inserter)
BodyInserter.inserter - the inserterBodyInserters@Deprecated WebTestClient.RequestHeadersSpec<?> syncBody(Object body)
body(Object)Object and perform the request.
This method is a convenient shortcut for:
.body(BodyInserters.fromObject(object))
The body can be a
MultiValueMap to create
a multipart request. The values in the MultiValueMap can be
any Object representing the body of the part, or an
HttpEntity representing a
part with body and headers. The MultiValueMap can be built
conveniently using
body - the Object to write to the requestIllegalArgumentException - if body is a Publisher or an
instance of a type supported by ReactiveAdapterRegistry.getSharedInstance(),
for which body(Publisher, Class) or body(Object, Class) should be used.