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 theAdapterCodecwith which request and response payloads are mapped.final BCalls the given consumer against this builder.autoAcceptEncoding(boolean autoAcceptEncoding) If enabled, each request will have anAccept-Encodingheader 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 newMethanolinstance.defaultHeader(String name, String value) Adds the given default header.defaultHeaders(String... headers) Adds each of the given default headers.defaultHeaders(Consumer<HeadersAccumulator<?>> configurator) Configures the default headers as specified by the given consumer.headersTimeout(Duration headersTimeout) Sets a timeout that will raise anHttpHeadersTimeoutExceptionif all response headers aren't received within the timeout.headersTimeout(Duration headersTimeout, ScheduledExecutorService scheduler) Same asheadersTimeout(Duration)but specifies aScheduledExecutorServiceto use for scheduling timeout events.interceptor(Methanol.Interceptor interceptor) Adds an interceptor that is invoked right after the client receives a request.final BpostDecorationInterceptor(Methanol.Interceptor interceptor) Deprecated.readTimeout(Duration readTimeout) Sets aread timeoutthat is applied to every request.readTimeout(Duration readTimeout, ScheduledExecutorService scheduler) Sets a defaultreadtimeoutthat is applied to very request, using the givenScheduledExecutorServicefor scheduling timeout events.requestTimeout(Duration requestTimeout) Sets a defaultto use on every request when no timeout is explicitly set on aninvalid reference
request timeoutHttpRequest.Builder.Sets a defaultUser-Agentheader to use when sending requests.
-
Method Details
-
apply
-
userAgent
Sets a defaultUser-Agentheader to use when sending requests.- Throws:
IllegalArgumentException- ifuserAgentis an invalid header value
-
baseUri
-
baseUri
-
defaultHeader
-
defaultHeaders
-
defaultHeaders
Configures the default headers as specified by the given consumer. -
requestTimeout
Sets a defaultto use on every request when no timeout is explicitly set on aninvalid reference
request timeoutHttpRequest.Builder. -
headersTimeout
Sets a timeout that will raise anHttpHeadersTimeoutExceptionif all response headers aren't received within the timeout. Timeout events are scheduled using a system-wideScheduledExecutorService. -
headersTimeout
@CanIgnoreReturnValue public B headersTimeout(Duration headersTimeout, ScheduledExecutorService scheduler) Same asheadersTimeout(Duration)but specifies aScheduledExecutorServiceto use for scheduling timeout events. -
readTimeout
Sets aread timeoutthat is applied to every request. Timeout events are scheduled using a system-wideScheduledExecutorService. -
readTimeout
@CanIgnoreReturnValue public B readTimeout(Duration readTimeout, ScheduledExecutorService scheduler) Sets a defaultreadtimeoutthat is applied to very request, using the givenScheduledExecutorServicefor scheduling timeout events. -
adapterCodec
Specifies theAdapterCodecwith which request and response payloads are mapped. -
autoAcceptEncoding
If enabled, each request will have anAccept-Encodingheader appended, the value of which is the set ofsupported encodings. Additionally, each received response will be transparently decompressed by wrapping itsBodyHandlerwithMoreBodyHandlers.decoding(BodyHandler).This value is
trueby default. -
interceptor
Adds an interceptor that is invoked right after the client receives a request. The interceptor receives the request before it is decorated (itsURIresolved 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 (itsURIresolved 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 anHttpCachethat is capable of serving a stored response. -
postDecorationInterceptor
@CanIgnoreReturnValue @Deprecated(since="1.5.0") @InlineMe(replacement="this.backendInterceptor(interceptor)") public final B postDecorationInterceptor(Methanol.Interceptor interceptor) Deprecated. -
build
Creates a newMethanolinstance.
-
backendInterceptor(Interceptor)