Class MapRemote

java.lang.Object
org.microproxy.extras.MapRemote
All Implemented Interfaces:
HttpFiltersSource

public final class MapRemote extends Object implements HttpFiltersSource
Sends requests to another URL, as mitmproxy's map_remote: each rule replaces every match of a regular expression in the request's absolute URL, and the request goes to the result. The Host header follows the new URL. Inside an intercepted session the request leaves the session's server for the new one, over TLS for https://.

 MapRemote.of("|https://api\\.example\\.com/v1/|http://localhost:8000/v1/",
              "|~m GET|example\\.org|example.net")
 

Specs are [|flow-filter]|url-regex|replacement, the separator being the first character. Every matching rule applies, in order, each to the URL the previous ones left. Replacements may use groups as Python does (\1, \g<name>) or as Java does ($1). Only heads are read, unless a rule's filter looks at the request body ( ~bq), which is then buffered (see MapRemote.Builder.maxBodySize).

  • Method Details

    • of

      public static MapRemote of(String... specs)
      Map remote rules from specs, with default settings.
      Parameters:
      specs - specs of the form [|flow-filter]|url-regex|replacement
      Returns:
      the addon
      Throws:
      IllegalArgumentException - if a spec is invalid
    • builder

      public static MapRemote.Builder builder()
      Starts a builder with no rules.
      Returns:
      a new builder
    • rules

      public List<MapRemote.Rule> rules()
      Returns the rules, in order.
      Returns:
      the rules, in order
    • filterRequest

      public HttpFilters filterRequest(HttpRequest originalRequest, FlowContext flowContext)
      Description copied from interface: HttpFiltersSource
      Returns the filters for a request, or null to proxy it unfiltered.
      Specified by:
      filterRequest in interface HttpFiltersSource
      Parameters:
      originalRequest - a copy of the request as received from the client
      flowContext - the client connection the request arrived on
      Returns:
      the per-request filters, or null to leave the request unfiltered