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 Detail

      • DEFAULT

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

      • beforeRequest

        java.net.http.HttpRequest beforeRequest​(Hook.BeforeRequestContext context,
                                                java.net.http.HttpRequest request)
                                         throws java.lang.Exception
        Transforms the given HttpRequest before sending.

        Note that HttpRequest is immutable. To modify the request you can use HttpRequest#newBuilder(HttpRequest, BiPredicate) 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:
        java.lang.Exception - on error