Interface Hook.BeforeRequest

All Known Implementing Classes:
Hook.IdempotencyHook, Hooks
Enclosing class:
Hook

public static interface Hook.BeforeRequest
Specifies how a request is transformed before sending.
  • Field Details

    • DEFAULT

      static final Hook.BeforeRequest DEFAULT
      The default action is to return the request untouched.
  • Method Details

    • beforeRequest

      HttpRequest beforeRequest(Hook.BeforeRequestContext context, HttpRequest request) throws Exception
      Transforms the given HttpRequest before sending.

      Note that HttpRequest is immutable. To modify the request you can use HttpRequest#newBuilder(HttpRequest, BiPredicate<String, String>) with JDK 16 and later (which will copy the request for modification in a builder). If that method is not available then use Helpers.copy(java.net.http.HttpRequest) (which also returns a builder).

      Parameters:
      context - context for the hook call
      request - request to be transformed
      Returns:
      transformed request
      Throws:
      Exception - on error