Class HttpUtils
java.lang.Object
dev.sympho.modular_commands.utils.HttpUtils
Utilities for working with HTTP requests.
- Since:
- 1.0
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Charset
getCharset
(reactor.netty.http.client.HttpClientResponse response) Retrives the charset used to encode an HTTP response.static <E extends RuntimeException>
CharsetgetCharset
(reactor.netty.http.client.HttpClientResponse response, Function<String, E> errorMapper) Retrives the charset used to encode an HTTP response.
-
Method Details
-
getCharset
@SideEffectFree public static <E extends RuntimeException> Charset getCharset(reactor.netty.http.client.HttpClientResponse response, Function<String, E> errorMapper) throws ERetrives 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.
-