Package com.intellectualsites.http
Class HttpClient.WrappedRequestBuilder
java.lang.Object
com.intellectualsites.http.HttpClient.WrappedRequestBuilder
- Enclosing class:
- HttpClient
Wrapper used to interact with HTTP requests.
-
Method Summary
Modifier and TypeMethodDescriptionexecute()Perform the requestonException(@NotNull Consumer<Throwable> consumer)Add an exception consumeronRemaining(@NotNull Consumer<HttpResponse> responseConsumer)Add a consumer that acts on all remaining status codeonStatus(int code, @NotNull Consumer<HttpResponse> responseConsumer)Add a consumer that acts on a specific status codewithHeader(@NotNull String key, @NotNull String value)Add a header to the requestSpecify an input supplier which will be used to write to the connection, if it established correctly.withMapper(@NotNull EntityMapper mapper)Specify the entity mapper used by the request
-
Method Details
-
withInput
@NotNull public @NotNull HttpClient.WrappedRequestBuilder withInput(@NotNull @NotNull Supplier<Object> input)Specify an input supplier which will be used to write to the connection, if it established correctly. This requires that there is aEntityMapper.EntitySerializerregistered for the type of the object, in theEntityMapperused by the client- Parameters:
input- Input- Returns:
- Builder instance
-
withMapper
@NotNull public @NotNull HttpClient.WrappedRequestBuilder withMapper(@NotNull @NotNull EntityMapper mapper)Specify the entity mapper used by the request- Parameters:
mapper- Entity mapper- Returns:
- Builder instance
-
withHeader
@NotNull public @NotNull HttpClient.WrappedRequestBuilder withHeader(@NotNull @NotNull String key, @NotNull @NotNull String value)Add a header to the request- Parameters:
key- Header keyvalue- Header value- Returns:
- Builder instance
-
onStatus
@NotNull public @NotNull HttpClient.WrappedRequestBuilder onStatus(int code, @NotNull @NotNull Consumer<HttpResponse> responseConsumer)Add a consumer that acts on a specific status code- Parameters:
code- Status coderesponseConsumer- Response consumer- Returns:
- Builder instance
-
onRemaining
@NotNull public @NotNull HttpClient.WrappedRequestBuilder onRemaining(@NotNull @NotNull Consumer<HttpResponse> responseConsumer)Add a consumer that acts on all remaining status code- Parameters:
responseConsumer- Response consumer- Returns:
- Builder instance
-
onException
@NotNull public @NotNull HttpClient.WrappedRequestBuilder onException(@NotNull @NotNull Consumer<Throwable> consumer)Add an exception consumer- Parameters:
consumer- Exception consumer- Returns:
- Builder instance
-
execute
Perform the request- Returns:
- The raw response, if no exception was thrown during the
handling of the response. If any exception was handled,
the method will return
null
-