Package io.avaje.http.client
Interface HttpClientContext
-
public interface HttpClientContext
The HTTP client context that we use to build and process requests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
HttpClientContext.Builder
Builds the HttpClientContext.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
checkResponse(HttpResponse<?> response)
Check the response status code and throw HttpException if the status code is in the error range.BodyAdapter
converters()
Return the body adapter used by the client context.byte[]
decodeContent(String encoding, byte[] content)
Decode the body using the given encoding.byte[]
decodeContent(HttpResponse<byte[]> httpResponse)
Decode the response content given theContent-Encoding
http header.HttpClient
httpClient()
Return the underlying http client.static HttpClientContext.Builder
newBuilder()
Return the builder to config and build the client context.BodyContent
readContent(HttpResponse<byte[]> httpResponse)
Return the response content taking into account content encoding.HttpClientRequest
request()
Create a new request.UrlBuilder
url()
Return a UrlBuilder to use to build an URL taking into account the base URL.
-
-
-
Method Detail
-
newBuilder
static HttpClientContext.Builder newBuilder()
Return the builder to config and build the client context.
-
request
HttpClientRequest request()
Create a new request.
-
url
UrlBuilder url()
Return a UrlBuilder to use to build an URL taking into account the base URL.
-
converters
BodyAdapter converters()
Return the body adapter used by the client context.
-
httpClient
HttpClient httpClient()
Return the underlying http client.
-
checkResponse
void checkResponse(HttpResponse<?> response)
Check the response status code and throw HttpException if the status code is in the error range.
-
readContent
BodyContent readContent(HttpResponse<byte[]> httpResponse)
Return the response content taking into account content encoding.- Parameters:
httpResponse
- The HTTP response to decode the content from- Returns:
- The decoded content
-
decodeContent
byte[] decodeContent(HttpResponse<byte[]> httpResponse)
Decode the response content given theContent-Encoding
http header.- Parameters:
httpResponse
- The HTTP response- Returns:
- The decoded content
-
decodeContent
byte[] decodeContent(String encoding, byte[] content)
Decode the body using the given encoding.- Parameters:
encoding
- The encoding used to decode the contentcontent
- The raw content being decoded- Returns:
- The decoded content
-
-