Class ResponseBuilder<T>
java.lang.Object
com.github.mizosoft.methanol.ResponseBuilder<T>
- All Implemented Interfaces:
HeadersAccumulator<ResponseBuilder<T>>
public final class ResponseBuilder<T>
extends Object
implements HeadersAccumulator<ResponseBuilder<T>>
A builder of
HttpResponse instances.-
Method Summary
Modifier and TypeMethodDescriptionapply(Consumer<? super ResponseBuilder<T>> mutator) <U> ResponseBuilder<U> body(@Nullable U body) build()cacheResponse(@Nullable TrackedResponse<?> cacheResponse) cacheStatus(CacheAwareResponse.CacheStatus cacheStatus) static <T> ResponseBuilder<T> create()Returns a newResponseBuilder.dropBody()static <T> ResponseBuilder<T> from(HttpResponse<T> response) Returns a newResponseBuilderthat copies the given response's state.Adds the given header name-value pair.Adds each of the given header name-value pairs.headers(HttpHeaders headers) Adds all the given headers.networkResponse(@Nullable TrackedResponse<?> networkResponse) previousResponse(@Nullable HttpResponse<T> previousResponse) removeHeader(String name) Removes all the header values associated with the given name.Removes all the headers added so far.removeHeadersIf(BiPredicate<String, String> filter) Removes all the header name-value pairs matched by the given predicate.request(HttpRequest request) Sets the header represented by the given name to the given value, overwriting the previous value (if any).Sets the header represented by the given name to the given values, overwriting the previous value (if any).setHeaderIfAbsent(String name, String value) Sets the header represented by the given name to the given value, only if there was no header with the given name.setHeaderIfAbsent(String name, List<String> values) Sets the header represented by the given name to the given values, only if there was no header with the given name.sslSession(@Nullable SSLSession sslSession) statusCode(int statusCode) timeRequestSent(Instant timeRequestSent) timeResponseReceived(Instant timeResponseReceived) version(HttpClient.Version version)
-
Method Details
-
apply
-
statusCode
-
uri
-
uri
-
version
-
header
Description copied from interface:HeadersAccumulatorAdds the given header name-value pair.- Specified by:
headerin interfaceHeadersAccumulator<T>
-
headers
Description copied from interface:HeadersAccumulatorAdds each of the given header name-value pairs. The pairs must be appended to each other in the given array, where each name is followed by a corresponding value.- Specified by:
headersin interfaceHeadersAccumulator<T>
-
headers
Description copied from interface:HeadersAccumulatorAdds all the given headers.- Specified by:
headersin interfaceHeadersAccumulator<T>
-
setHeader
Description copied from interface:HeadersAccumulatorSets the header represented by the given name to the given value, overwriting the previous value (if any).- Specified by:
setHeaderin interfaceHeadersAccumulator<T>
-
setHeader
Description copied from interface:HeadersAccumulatorSets the header represented by the given name to the given values, overwriting the previous value (if any).- Specified by:
setHeaderin interfaceHeadersAccumulator<T>
-
setHeaderIfAbsent
Description copied from interface:HeadersAccumulatorSets the header represented by the given name to the given value, only if there was no header with the given name.- Specified by:
setHeaderIfAbsentin interfaceHeadersAccumulator<T>
-
setHeaderIfAbsent
Description copied from interface:HeadersAccumulatorSets the header represented by the given name to the given values, only if there was no header with the given name.- Specified by:
setHeaderIfAbsentin interfaceHeadersAccumulator<T>
-
removeHeaders
Description copied from interface:HeadersAccumulatorRemoves all the headers added so far.- Specified by:
removeHeadersin interfaceHeadersAccumulator<T>
-
removeHeader
Description copied from interface:HeadersAccumulatorRemoves all the header values associated with the given name.- Specified by:
removeHeaderin interfaceHeadersAccumulator<T>
-
removeHeadersIf
Description copied from interface:HeadersAccumulatorRemoves all the header name-value pairs matched by the given predicate.- Specified by:
removeHeadersIfin interfaceHeadersAccumulator<T>
-
request
-
timeRequestSent
-
timeResponseReceived
-
body
-
dropBody
-
sslSession
-
previousResponse
@CanIgnoreReturnValue public ResponseBuilder<T> previousResponse(@Nullable HttpResponse<T> previousResponse) -
networkResponse
@CanIgnoreReturnValue public ResponseBuilder<T> networkResponse(@Nullable TrackedResponse<?> networkResponse) -
cacheResponse
@CanIgnoreReturnValue public ResponseBuilder<T> cacheResponse(@Nullable TrackedResponse<?> cacheResponse) -
cacheStatus
@CanIgnoreReturnValue public ResponseBuilder<T> cacheStatus(CacheAwareResponse.CacheStatus cacheStatus) -
build
-
buildTrackedResponse
-
buildCacheAwareResponse
-
create
Returns a newResponseBuilder. -
from
Returns a newResponseBuilderthat copies the given response's state.
-