public static interface WebTestClient.RequestBodySpec extends WebTestClient.RequestHeadersSpec<WebTestClient.RequestBodySpec>
Modifier and Type | Method and Description |
---|---|
WebTestClient.RequestHeadersSpec<?> |
body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the given
BodyInserter . |
<T,S extends org.reactivestreams.Publisher<T>> |
body(S publisher,
Class<T> elementClass)
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(MediaType contentType)
Set the media type of the body, as specified
by the
Content-Type header. |
WebTestClient.RequestHeadersSpec<?> |
syncBody(Object body)
Set the body of the request to the given synchronous
Object and
perform the request. |
accept, acceptCharset, attribute, attributes, cookie, cookies, exchange, header, headers, ifModifiedSince, ifNoneMatch
WebTestClient.RequestBodySpec contentLength(long contentLength)
Content-Length
header.contentLength
- the content lengthHttpHeaders.setContentLength(long)
WebTestClient.RequestBodySpec contentType(MediaType contentType)
Content-Type
header.contentType
- the content typeHttpHeaders.setContentType(MediaType)
WebTestClient.RequestHeadersSpec<?> body(BodyInserter<?,? super ClientHttpRequest> inserter)
BodyInserter
.inserter
- the inserterBodyInserters
<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 Publisher
publisher
- the request body dataelementClass
- the class of elements contained in the publisherWebTestClient.RequestHeadersSpec<?> syncBody(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 requestMono
with the response