Module methanol
Package com.github.mizosoft.methanol
Class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>>
java.lang.Object
com.github.mizosoft.methanol.Methanol.BaseBuilder<B>
- Direct Known Subclasses:
Methanol.Builder
,Methanol.WithClientBuilder
- Enclosing class:
Methanol
A base
Methanol
builder allowing to set the non-standard properties.-
Method Summary
Modifier and TypeMethodDescriptionadapterCodec
(AdapterCodec adapterCodec) Specifies theAdapterCodec
with which request and response payloads are mapped.final B
Calls the given consumer against this builder.autoAcceptEncoding
(boolean autoAcceptEncoding) If enabled, each request will have anAccept-Encoding
header appended, the value of which is the set ofsupported encodings
.backendInterceptor
(Methanol.Interceptor interceptor) Adds an interceptor that is invoked right before the request is forwarded to the client's backend.build()
Creates a newMethanol
instance.defaultHeader
(String name, String value) Adds the given default header.defaultHeaders
(String... headers) Adds each of the given default headers.headersTimeout
(Duration headersTimeout) Sets a timeout that will raise anHttpHeadersTimeoutException
if all response headers aren't received within the timeout.headersTimeout
(Duration headersTimeout, ScheduledExecutorService scheduler) Same asheadersTimeout(Duration)
but specifies aScheduledExecutorService
to use for scheduling timeout events.interceptor
(Methanol.Interceptor interceptor) Adds an interceptor that is invoked right after the client receives a request.postDecorationInterceptor
(Methanol.Interceptor interceptor) Deprecated.readTimeout
(Duration readTimeout) Sets a defaultread timeout
.readTimeout
(Duration readTimeout, ScheduledExecutorService scheduler) Sets a defaultreadtimeout
using the givenScheduledExecutorService
for scheduling timeout events.requestTimeout
(Duration requestTimeout) Sets a default request timeout to use when not explicitly by anHttpRequest
.Sets a defaultUser-Agent
header to use when sending requests.
-
Method Details
-
apply
Calls the given consumer against this builder. -
userAgent
Sets a defaultUser-Agent
header to use when sending requests.- Throws:
IllegalArgumentException
- ifuserAgent
is an invalid header value
-
baseUri
-
baseUri
-
defaultHeader
Adds the given default header. -
defaultHeaders
Adds each of the given default headers. -
requestTimeout
Sets a default request timeout to use when not explicitly by anHttpRequest
. -
headersTimeout
Sets a timeout that will raise anHttpHeadersTimeoutException
if all response headers aren't received within the timeout. Timeout events are scheduled using a system-wideScheduledExecutorService
. -
headersTimeout
Same asheadersTimeout(Duration)
but specifies aScheduledExecutorService
to use for scheduling timeout events. -
readTimeout
Sets a defaultread timeout
. Timeout events are scheduled using a system-wideScheduledExecutorService
. -
readTimeout
Sets a defaultreadtimeout
using the givenScheduledExecutorService
for scheduling timeout events. -
adapterCodec
Specifies theAdapterCodec
with which request and response payloads are mapped. -
autoAcceptEncoding
If enabled, each request will have anAccept-Encoding
header appended, the value of which is the set ofsupported encodings
. Additionally, each received response will be transparently decompressed by wrapping itsBodyHandler
withMoreBodyHandlers.decoding(BodyHandler)
.This value is
true
by default. -
interceptor
Adds an interceptor that is invoked right after the client receives a request. The interceptor receives the request before it is decorated (itsURI
resolved with the baseURI
, default headers added, etc...) or handled by anHttpCache
. -
backendInterceptor
Adds an interceptor that is invoked right before the request is forwarded to the client's backend. The interceptor receives the request after it is handled by allclient interceptors
, is decorated (itsURI
resolved with the baseURI
, default headers added, etc...) and finally handled by anHttpCache
. This implies that backend interceptors aren't called if network isn't used, normally due to the presence of anHttpCache
that is capable of serving a stored response. -
postDecorationInterceptor
Deprecated. -
build
Creates a newMethanol
instance.
-
backendInterceptor(Interceptor)