Module bus.http

Class Httpv.Builder

java.lang.Object
org.miaixz.bus.http.Httpv.Builder
Enclosing class:
Httpv

public static class Httpv.Builder extends Object
A builder for creating and configuring Httpv instances.
  • Constructor Details

    • Builder

      public Builder()
      Default constructor that initializes with default values.
    • Builder

      public Builder(Httpv httpv)
      Constructor that initializes the builder with the settings of an existing Httpv instance.
      Parameters:
      httpv - The Httpv instance to copy settings from.
  • Method Details

    • config

      public Httpv.Builder config(Httpv.HttpvConfig config)
      Sets a configurer for the underlying Httpd.Builder.
      Parameters:
      config - The configurer.
      Returns:
      This builder.
    • baseUrl

      public Httpv.Builder baseUrl(String baseUrl)
      Sets the base URL for all requests.
      Parameters:
      baseUrl - The base URL.
      Returns:
      This builder.
    • mediaTypes

      public Httpv.Builder mediaTypes(Map<String,String> mediaTypes)
      Adds multiple media type mappings.
      Parameters:
      mediaTypes - A map of media types.
      Returns:
      This builder.
    • mediaTypes

      public Httpv.Builder mediaTypes(String key, String value)
      Adds a single media type mapping.
      Parameters:
      key - The file extension or type key.
      value - The media type value.
      Returns:
      This builder.
    • callbackExecutor

      public Httpv.Builder callbackExecutor(Executor executor)
      Sets the executor for callbacks, allowing thread switching for asynchronous requests.
      Parameters:
      executor - The callback executor.
      Returns:
      This builder.
    • addPreprocessor

      public Httpv.Builder addPreprocessor(Preprocessor preprocessor)
      Adds a preprocessor that can run in parallel with other preprocessors.
      Parameters:
      preprocessor - The preprocessor to add.
      Returns:
      This builder.
    • addSerialPreprocessor

      public Httpv.Builder addSerialPreprocessor(Preprocessor preprocessor)
      Adds a preprocessor that will be executed serially.
      Parameters:
      preprocessor - The preprocessor to add.
      Returns:
      This builder.
    • preprocTimeoutTimes

      public Httpv.Builder preprocTimeoutTimes(int times)
      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

      public Httpv.Builder responseListener(CoverTasks.Listener<CoverResult> listener)
      Sets a global listener for successful responses.
      Parameters:
      listener - The response listener.
      Returns:
      This builder.
    • exceptionListener

      public Httpv.Builder exceptionListener(CoverTasks.Listener<IOException> listener)
      Sets a global listener for exceptions.
      Parameters:
      listener - The exception listener.
      Returns:
      This builder.
    • completeListener

      public Httpv.Builder completeListener(CoverTasks.Listener<CoverResult.State> listener)
      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

      public Httpv.Builder downloadListener(Downloads.Listener listener)
      Sets a listener for download progress.
      Parameters:
      listener - The download listener.
      Returns:
      This builder.
    • addMsgConvertor

      public Httpv.Builder addMsgConvertor(Convertor convertor)
      Adds a message converter for handling different response formats.
      Parameters:
      convertor - The message converter.
      Returns:
      This builder.
    • charset

      public Httpv.Builder charset(Charset charset)
      Sets the default charset for request bodies.
      Parameters:
      charset - The charset.
      Returns:
      This builder.
    • bodyType

      public Httpv.Builder bodyType(String bodyType)
      Sets the default body type for requests.
      Parameters:
      bodyType - The body type (e.g., "form", "json").
      Returns:
      This builder.
    • build

      public Httpv build()
      Builds a new Httpv instance with the configured settings.
      Returns:
      A new Httpv instance.
    • httpd

      public Httpd httpd()
      Returns:
      The underlying Httpd instance.
    • baseUrl

      public String baseUrl()
      Returns:
      The configured base URL.
    • getMediaTypes

      public Map<String,String> getMediaTypes()
      Returns:
      The map of media types.
    • mainExecutor

      public Executor mainExecutor()
      Returns:
      The main executor for callbacks.
    • preprocessors

      public Preprocessor[] preprocessors()
      Returns:
      An array of configured preprocessors.
    • downloadListener

      public Downloads.Listener downloadListener()
      Returns:
      The download listener.
    • responseListener

      public CoverTasks.Listener<CoverResult> responseListener()
      Returns:
      The response listener.
    • exceptionListener

      public CoverTasks.Listener<IOException> exceptionListener()
      Returns:
      The exception listener.
    • completeListener

      public CoverTasks.Listener<CoverResult.State> completeListener()
      Returns:
      The completion listener.
    • msgConvertors

      public Convertor[] msgConvertors()
      Returns:
      An array of configured message converters.
    • preprocTimeoutTimes

      public int preprocTimeoutTimes()
      Returns:
      The pre-processing timeout multiplier.
    • charset

      public Charset charset()
      Returns:
      The default charset.
    • bodyType

      public String bodyType()
      Returns:
      The default body type.