Class HttpUtils

java.lang.Object
dev.sympho.modular_commands.utils.HttpUtils

public final class HttpUtils extends Object
Utilities for working with HTTP requests.
Since:
1.0
Version:
1.0
  • Method Details

    • getCharset

      @SideEffectFree public static <E extends RuntimeException> Charset getCharset(reactor.netty.http.client.HttpClientResponse response, Function<String,E> errorMapper) throws E
      Retrives the charset used to encode an HTTP response.

      Also checks that the request succeeded, throwing a custom exception if it did not.

      Type Parameters:
      E - The exception type to throw if the request did not succeed.
      Parameters:
      response - The response metadata.
      errorMapper - The function to use to generate an exception with a given error message.
      Returns:
      The encoding charset.
      Throws:
      E - if the request did not succeed.
    • getCharset

      @SideEffectFree public static Charset getCharset(reactor.netty.http.client.HttpClientResponse response) throws IllegalStateException
      Retrives the charset used to encode an HTTP response.

      Also checks that the request succeeded.

      Parameters:
      response - The response metadata.
      Returns:
      The encoding charset.
      Throws:
      IllegalStateException - if the request did not succeed.