Interface WebTestClient.RequestBodySpec

All Superinterfaces:
WebTestClient.RequestHeadersSpec<WebTestClient.RequestBodySpec>
All Known Subinterfaces:
WebTestClient.RequestBodyUriSpec
Enclosing interface:
WebTestClient

public static interface WebTestClient.RequestBodySpec extends WebTestClient.RequestHeadersSpec<WebTestClient.RequestBodySpec>
Specification for providing body of a request.
  • Method Details

    • contentLength

      WebTestClient.RequestBodySpec contentLength(long contentLength)
      Set the length of the body in bytes, as specified by the Content-Length header.
      Parameters:
      contentLength - the content length
      Returns:
      the same instance
      See Also:
      • HttpHeaders.setContentLength(long)
    • contentType

      WebTestClient.RequestBodySpec contentType(org.springframework.http.MediaType contentType)
      Set the media type of the body, as specified by the Content-Type header.
      Parameters:
      contentType - the content type
      Returns:
      the same instance
      See Also:
      • HttpHeaders.setContentType(MediaType)
    • bodyValue

      Set the body to the given Object value. This method invokes the bodyValue method on the underlying WebClient.
      Parameters:
      body - the value to write to the request body
      Returns:
      spec for further declaration of the request
      Since:
      5.2
    • body

      <T, S extends Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, Class<T> elementClass)
      Set the body from the given Publisher. Shortcut for body(BodyInserter) with a Publisher inserter.
      Type Parameters:
      T - the type of the elements contained in the publisher
      S - the type of the Publisher
      Parameters:
      publisher - the request body data
      elementClass - the class of elements contained in the publisher
      Returns:
      spec for further declaration of the request
    • body

      <T, S extends Publisher<T>> WebTestClient.RequestHeadersSpec<?> body(S publisher, org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)
      Variant of body(Publisher, Class) that allows providing element type information with generics.
      Type Parameters:
      T - the type of the elements contained in the publisher
      S - the type of the Publisher
      Parameters:
      publisher - the request body data
      elementTypeRef - the type reference of elements contained in the publisher
      Returns:
      spec for further declaration of the request
      Since:
      5.2
    • body

      WebTestClient.RequestHeadersSpec<?> body(Object producer, Class<?> elementClass)
      Set the body from the given producer. This method invokes the body(Object, Class) method on the underlying WebClient.
      Parameters:
      producer - the producer to write to the request. This must be a Publisher or another producer adaptable to a Publisher via ReactiveAdapterRegistry
      elementClass - the class of elements contained in the producer
      Returns:
      spec for further declaration of the request
      Since:
      5.2
    • body

      WebTestClient.RequestHeadersSpec<?> body(Object producer, org.springframework.core.ParameterizedTypeReference<?> elementTypeRef)
      Set the body from the given producer. This method invokes the body(Object, ParameterizedTypeReference) method on the underlying WebClient.
      Parameters:
      producer - the producer to write to the request. This must be a Publisher or another producer adaptable to a Publisher via ReactiveAdapterRegistry
      elementTypeRef - the type reference of elements contained in the producer
      Returns:
      spec for further declaration of the request
      Since:
      5.2
    • body

      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. This method invokes the body(BodyInserter) method on the underlying WebClient.
      Parameters:
      inserter - the body inserter to use
      Returns:
      spec for further declaration of the request
      See Also:
      • BodyInserters
    • syncBody

      Deprecated.
      as of Spring Framework 5.2 in favor of bodyValue(Object)
      Shortcut for body(BodyInserter) with a value inserter. As of 5.2 this method delegates to bodyValue(Object).