java.lang.Object
org.miaixz.bus.http.Httpv.Builder
- Enclosing class:
Httpv
A builder for creating and configuring
Httpv instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMsgConvertor(Convertor convertor) Adds a message converter for handling different response formats.addPreprocessor(Preprocessor preprocessor) Adds a preprocessor that can run in parallel with other preprocessors.addSerialPreprocessor(Preprocessor preprocessor) Adds a preprocessor that will be executed serially.baseUrl()Sets the base URL for all requests.bodyType()Sets the default body type for requests.build()Builds a newHttpvinstance with the configured settings.callbackExecutor(Executor executor) Sets the executor for callbacks, allowing thread switching for asynchronous requests.charset()Sets the default charset for request bodies.completeListener(CoverTasks.Listener<CoverResult.State> listener) Sets a global listener for when a request is completed (either successfully or with an error).config(Httpv.HttpvConfig config) Sets a configurer for the underlyingHttpd.Builder.downloadListener(Downloads.Listener listener) Sets a listener for download progress.exceptionListener(CoverTasks.Listener<IOException> listener) Sets a global listener for exceptions.httpd()mediaTypes(String key, String value) Adds a single media type mapping.mediaTypes(Map<String, String> mediaTypes) Adds multiple media type mappings.intpreprocTimeoutTimes(int times) Sets the maximum pre-processing time multiplier relative to the normal request timeout.responseListener(CoverTasks.Listener<CoverResult> listener) Sets a global listener for successful responses.
-
Constructor Details
-
Method Details
-
config
Sets a configurer for the underlyingHttpd.Builder.- Parameters:
config- The configurer.- Returns:
- This builder.
-
baseUrl
Sets the base URL for all requests.- Parameters:
baseUrl- The base URL.- Returns:
- This builder.
-
mediaTypes
Adds multiple media type mappings.- Parameters:
mediaTypes- A map of media types.- Returns:
- This builder.
-
mediaTypes
Adds a single media type mapping.- Parameters:
key- The file extension or type key.value- The media type value.- Returns:
- This builder.
-
callbackExecutor
Sets the executor for callbacks, allowing thread switching for asynchronous requests.- Parameters:
executor- The callback executor.- Returns:
- This builder.
-
addPreprocessor
Adds a preprocessor that can run in parallel with other preprocessors.- Parameters:
preprocessor- The preprocessor to add.- Returns:
- This builder.
-
addSerialPreprocessor
Adds a preprocessor that will be executed serially.- Parameters:
preprocessor- The preprocessor to add.- Returns:
- This builder.
-
preprocTimeoutTimes
Sets the maximum pre-processing time multiplier relative to the normal request timeout.- Parameters:
times- The multiplier for the timeout, default is 10.- Returns:
- This builder.
-
responseListener
Sets a global listener for successful responses.- Parameters:
listener- The response listener.- Returns:
- This builder.
-
exceptionListener
Sets a global listener for exceptions.- Parameters:
listener- The exception listener.- Returns:
- This builder.
-
completeListener
Sets a global listener for when a request is completed (either successfully or with an error).- Parameters:
listener- The completion listener.- Returns:
- This builder.
-
downloadListener
Sets a listener for download progress.- Parameters:
listener- The download listener.- Returns:
- This builder.
-
addMsgConvertor
Adds a message converter for handling different response formats.- Parameters:
convertor- The message converter.- Returns:
- This builder.
-
charset
Sets the default charset for request bodies.- Parameters:
charset- The charset.- Returns:
- This builder.
-
bodyType
Sets the default body type for requests.- Parameters:
bodyType- The body type (e.g., "form", "json").- Returns:
- This builder.
-
build
Builds a newHttpvinstance with the configured settings.- Returns:
- A new
Httpvinstance.
-
httpd
- Returns:
- The underlying
Httpdinstance.
-
baseUrl
- Returns:
- The configured base URL.
-
getMediaTypes
- Returns:
- The map of media types.
-
mainExecutor
- Returns:
- The main executor for callbacks.
-
preprocessors
- Returns:
- An array of configured preprocessors.
-
downloadListener
- Returns:
- The download listener.
-
responseListener
- Returns:
- The response listener.
-
exceptionListener
- Returns:
- The exception listener.
-
completeListener
- Returns:
- The completion listener.
-
msgConvertors
- Returns:
- An array of configured message converters.
-
preprocTimeoutTimes
public int preprocTimeoutTimes()- Returns:
- The pre-processing timeout multiplier.
-
charset
- Returns:
- The default charset.
-
bodyType
- Returns:
- The default body type.
-