Class HttpRequest

    • Constructor Detail

      • HttpRequest

        public HttpRequest​(java.lang.String method,
                           java.lang.String url)
                    throws java.net.MalformedURLException
        Throws:
        java.net.MalformedURLException
      • HttpRequest

        public HttpRequest​(java.lang.String method,
                           java.net.URL url)
    • Method Detail

      • getMethod

        public java.lang.String getMethod()
        Returns:
        The request method
      • getURL

        public java.net.URL getURL()
        Returns:
        The request url
      • isStreamedRequest

        public boolean isStreamedRequest()
        Returns:
        If the request should be streamed
      • setStreamedRequest

        public HttpRequest setStreamedRequest​(boolean streamedRequest)
        Set if the request should be streamed.
        Streaming the request will not buffer the content and will allow you to write the content while it is being uploaded.
        Streaming is not a mandatory feature and might not be supported by all executors.
        Parameters:
        streamedRequest - If the request should be streamed
        Returns:
        This instance for chaining
      • isStreamedResponse

        public boolean isStreamedResponse()
        Returns:
        If the response should be streamed
      • setStreamedResponse

        public HttpRequest setStreamedResponse​(boolean streamedResponse)
        Set if the response should be streamed.
        Streaming the response will not buffer the content and will allow you to read the content while it is being downloaded.
        You are responsible for closing the input stream of the response to close the connection and free resources.
        Streaming is not a mandatory feature and might not be supported by all executors.
        Parameters:
        streamedResponse - If the response should be streamed
        Returns:
        This instance for chaining
      • setFollowRedirects

        public HttpRequest setFollowRedirects​(boolean followRedirects)
        Set if redirects should be followed.
        Parameters:
        followRedirects - If redirects should be followed
        Returns:
        This instance for chaining
      • setFollowRedirects

        public HttpRequest setFollowRedirects​(@Nonnull
                                              HttpRequest.FollowRedirects followRedirects)
        Set if redirects should be followed.
        Parameters:
        followRedirects - If redirects should be followed
        Returns:
        This instance for chaining
      • isCookieManagerSet

        public boolean isCookieManagerSet()
        Returns:
        If the cookie manager is set
      • unsetCookieManager

        public HttpRequest unsetCookieManager()
        Unset the cookie manager.
        Returns:
        This instance for chaining
      • getCookieManager

        @Nullable
        public java.net.CookieManager getCookieManager()
        Returns:
        The set cookie manager
        Throws:
        java.lang.IllegalStateException - If the cookie manager is not set
      • setCookieManager

        public HttpRequest setCookieManager​(@Nullable
                                            java.net.CookieManager cookieManager)
        Set the cookie manager to use for this request.
        Parameters:
        cookieManager - The cookie manager to use
        Returns:
        This instance for chaining
      • isRetryHandlerSet

        public boolean isRetryHandlerSet()
        Returns:
        If the retry handler is set
      • unsetRetryHandler

        public HttpRequest unsetRetryHandler()
        Unset the retry handler.
        Returns:
        This instance for chaining
      • getRetryHandler

        @Nonnull
        public RetryConfig getRetryHandler()
        Returns:
        The set retry handler
        Throws:
        java.lang.IllegalStateException - If the retry handler is not set
      • setRetryHandler

        public HttpRequest setRetryHandler​(@Nonnull
                                           RetryConfig retryConfig)
        Set the retry handler to use for this request.
        Parameters:
        retryConfig - The retry handler to use
        Returns:
        This instance for chaining
      • isIgnoreInvalidSSLSet

        public boolean isIgnoreInvalidSSLSet()
        Returns:
        If the ignore invalid SSL flag is set
      • unsetIgnoreInvalidSSL

        public HttpRequest unsetIgnoreInvalidSSL()
        Unset the ignore invalid SSL flag.
        Returns:
        This instance for chaining
      • getIgnoreInvalidSSL

        public boolean getIgnoreInvalidSSL()
        Returns:
        The set ignore invalid SSL flag
        Throws:
        java.lang.IllegalStateException - If the ignore invalid SSL flag is not set
      • setIgnoreInvalidSSL

        public HttpRequest setIgnoreInvalidSSL​(boolean ignoreInvalidSSL)
        Set the ignore invalid SSL flag to use for this request.
        Parameters:
        ignoreInvalidSSL - The ignore invalid SSL flag to use
        Returns:
        This instance for chaining
      • bind

        public HttpRequest bind​(@Nullable
                                HttpClient client)
        Bind this request to a client for execution.
        Parameters:
        client - The client to bind to
        Returns:
        This instance for chaining
      • execute

        public HttpResponse execute()
                             throws java.io.IOException
        Execute this request and return the response.
        If a client is bound to this request it will be used for execution.
        If no client is bound a new client will be created.
        Returns:
        The response of the request
        Throws:
        java.io.IOException - If an I/O error occurs
      • execute

        public <R> R execute​(HttpResponseHandler<R> responseHandler)
                      throws java.io.IOException
        Execute this request and pass the response to the response handler.
        If a client is bound to this request it will be used for execution.
        If no client is bound a new client will be created.
        Type Parameters:
        R - The return type of the response handler
        Parameters:
        responseHandler - The response handler
        Returns:
        The return value of the response handler
        Throws:
        java.io.IOException - If an I/O error occurs