Class ServerReplay.Builder

java.lang.Object
org.microproxy.extras.ServerReplay.Builder
Enclosing class:
ServerReplay

public static final class ServerReplay.Builder extends Object
Configures a ServerReplay.
  • Method Details

    • load

      public ServerReplay.Builder load(Path path) throws IOException
      Adds the exchanges recorded in a HAR or WARC file, or in every such file of a directory (see RecordedExchange.load(java.nio.file.Path)).
      Parameters:
      path - a file or directory
      Returns:
      this builder
      Throws:
      IOException - if a file cannot be read or is in neither format
    • add

      Adds recorded exchanges.
      Parameters:
      recorded - the exchanges, in recorded order
      Returns:
      this builder
    • ignoreContent

      public ServerReplay.Builder ignoreContent(boolean ignore)
      Ignores request bodies when matching (default false).
      Parameters:
      ignore - whether to ignore bodies
      Returns:
      this builder
    • ignoreHost

      public ServerReplay.Builder ignoreHost(boolean ignore)
      Ignores the host when matching (default false).
      Parameters:
      ignore - whether to ignore the host
      Returns:
      this builder
    • ignorePort

      public ServerReplay.Builder ignorePort(boolean ignore)
      Ignores the port when matching (default false).
      Parameters:
      ignore - whether to ignore the port
      Returns:
      this builder
    • ignoreParams

      public ServerReplay.Builder ignoreParams(String... names)
      Query parameters to ignore when matching.
      Parameters:
      names - parameter names
      Returns:
      this builder
    • ignorePayloadParams

      public ServerReplay.Builder ignorePayloadParams(String... names)
      Form fields of application/x-www-form-urlencoded bodies to ignore when matching; the other fields are compared instead of the whole body.
      Parameters:
      names - field names
      Returns:
      this builder
    • useHeaders

      public ServerReplay.Builder useHeaders(String... names)
      Request headers that must match too.
      Parameters:
      names - header names
      Returns:
      this builder
    • reuse

      public ServerReplay.Builder reuse(boolean reuse)
      Keeps answering with a recording rather than using it up (default false: each answers once).
      Parameters:
      reuse - whether recordings can be replayed any number of times
      Returns:
      this builder
    • extra

      What happens to requests without a recording (default ServerReplay.Extra.forward()).
      Parameters:
      extra - forward, kill or a status
      Returns:
      this builder
    • refresh

      public ServerReplay.Builder refresh(boolean refresh)
      Shifts the dates of replayed responses by the time since they were recorded (default true).
      Parameters:
      refresh - whether to refresh dates
      Returns:
      this builder
    • maxBodySize

      public ServerReplay.Builder maxBodySize(int bytes)
      Largest request body buffered to compare it (default 16 MiB); a larger one is answered with 413, unless bodies are ignored.
      Parameters:
      bytes - the buffer limit
      Returns:
      this builder
    • build

      public ServerReplay build()
      Creates the addon.
      Returns:
      the configured addon