Class UHttpResponse

java.lang.Object
ushiosan.jvm.http.UHttpResponse

public final class UHttpResponse extends Object
  • Method Details

    • detectError

      @NotNull public static @NotNull Optional<UPair<Integer,String>> detectError(@NotNull @NotNull HttpResponse<?> response)
      Detect if there is a possible error within the http response
      Parameters:
      response - the http response to be verified
      Returns:
      the error code contained in the http response or Optional.empty() if the http response is valid
    • detectRedirect

      @NotNull public static @NotNull Optional<UPair<Integer,String>> detectRedirect(@NotNull @NotNull HttpResponse<?> response)
      Detect if there is a possible redirection within the http response
      Parameters:
      response - the http response to be verified
      Returns:
      the redirection code contained in the http response or Optional.empty() if there is no redirect code
    • requestHeaders

      @NotNull public static @NotNull CompletableFuture<HttpResponse<Void>> requestHeaders(@NotNull @NotNull URI uri, @NotNull @NotNull HttpClient client, boolean preventErrors)
      Send an HTTP request (HEAD) with no content and no response, to get the headers of the requested content.
      Parameters:
      uri - the route to which you want to send the request
      client - the http client to send the request
      preventErrors - option used to throw an error if the http response is not valid (error codes 400 or 500)
      Returns:
      the response without content of the http request (This response is only used to get the headers)
    • requestHeaders

      Send an HTTP request (HEAD) with no content and no response, to get the headers of the requested content.
      Parameters:
      uri - the route to which you want to send the request
      client - the http client to send the request
      Returns:
      the response without content of the http request (This response is only used to get the headers)
    • validateUri

      @NotNull public static @NotNull CompletableFuture<URI> validateUri(@NotNull @NotNull URI uri, @NotNull @NotNull HttpClient client, boolean preventErrors)
      Method used to validate the url.

      This means that it will be verified if the url does not return a 400 or 500 errors and also if this is not a redirect url. If it is a redirect url, then the url of the content being redirected to is returned instead of the original url (recursively).

      Parameters:
      uri - the route to which you want to send the request
      client - the http client to send the request
      preventErrors - option used to throw an error if the http response is not valid (error codes 400 or 500)
      Returns:
      the valid url to send a http request
    • validateUri

      Method used to validate the url.

      This means that it will be verified if the url does not return a 400 or 500 errors and also if this is not a redirect url. If it is a redirect url, then the url of the content being redirected to is returned instead of the original url (recursively).

      Parameters:
      uri - the route to which you want to send the request
      client - the http client to send the request
      Returns:
      the valid url to send a http request