Class RecordingClient

  • All Implemented Interfaces:
    HTTPClient

    public final class RecordingClient
    extends java.lang.Object
    implements HTTPClient
    • Constructor Detail

      • RecordingClient

        public RecordingClient()
    • Method Detail

      • send

        public java.net.http.HttpResponse<java.io.InputStream> send​(java.net.http.HttpRequest request)
                                                             throws java.io.IOException,
                                                                    java.lang.InterruptedException,
                                                                    java.net.URISyntaxException
        Description copied from interface: HTTPClient
        Sends an HTTP request and returns the response.

        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).

        Specified by:
        send in interface HTTPClient
        Parameters:
        request - HTTP request
        Returns:
        HTTP response
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.net.URISyntaxException
      • requests

        public java.util.List<java.net.http.HttpRequest> requests()
      • beforeRequest

        public RecordingClient beforeRequest​(java.util.function.UnaryOperator<java.net.http.HttpRequest> hook)
      • afterResponse

        public RecordingClient afterResponse​(java.util.function.UnaryOperator<java.net.http.HttpResponse<java.io.InputStream>> hook)
      • reset

        public void reset()