Interface RequestCallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @Deprecated(since="7.1", forRemoval=true) public interface RequestCallback
Deprecated, for removal: This API element is subject to removal in a future version.
Callback interface for code that operates on a ClientHttpRequest. Allows manipulating the request headers, and write to the request body.

Used internally by the RestTemplate, but also useful for application code. There several available factory methods:

Since:
3.0
Author:
Arjen Poutsma
See Also:
  • Method Details

    • doWithRequest

      void doWithRequest(ClientHttpRequest request) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets called by RestTemplate.execute(String, HttpMethod, RequestCallback, ResponseExtractor, Object...) with an opened ClientHttpRequest. Does not need to care about closing the request or about handling errors: this will all be handled by the RestTemplate.

      Note: In order to stream request body content directly to the underlying HTTP library, implementations must check if the request is an implementation of StreamingHttpOutputMessage, and set the request body through it. Use of the HttpOutputMessage.getBody() is also supported, but results in full content aggregation prior to execution. All built-in request implementations support StreamingHttpOutputMessage.

      Parameters:
      request - the active HTTP request
      Throws:
      IOException - in case of I/O errors