Class FlowFilter
MapLocal, MapRemote, ModifyBody, ModifyHeaders, BlockList,
AntiCache, StickyCookie, HarRecorder) take to choose the exchanges they
act on.
| expression | matches |
|---|---|
~u regex, or a bare regex | the URL (absolute, https://
inside intercepted sessions), normalized: lower-case scheme and host, no user info, no
trailing dot on the host, the port as the proxy reads it (:080, :+80 and
: are port 80) and dropped when it is the scheme's default, escapes of
unreserved characters (letters, digits, - . _ ~) decoded and other escapes in
upper-case hex, and dot segments removed from the path. Escaped / and \,
; parameters and // are left as they are. A rule that looks for something
the normalized URL cannot have logs a warning when parsed |
~d regex | the request's host |
~m regex | the method |
~h regex, ~hq regex, ~hs regex | a header line (
Name: value) of the request or the response, the request, the response |
~t regex, ~tq regex, ~ts regex | the
Content-Type of the request or the response, the request, the response |
~b regex, ~bq regex, ~bs regex | the decoded body of the request or the response, the request, the response |
~c code | the response status |
~q, ~s | a request without a response yet, an exchange with a response |
~a | an asset response: CSS, JavaScript, images, fonts |
~all | everything |
!x, x & y, x | y, (x) | not, and, or, grouping |
! binds tightest, then &, then |; expressions written next to each
other are joined by "and" with the lowest precedence of all, as in mitmproxy (a b | c
means a & (b | c)). Regular expressions are java.util.regex patterns,
searched for anywhere in the subject, ignoring case. One that contains spaces or any of
( ) ~ ' " goes in single or double quotes; inside quotes a backslash escapes only the quote
and itself, so "\d+ items" keeps its \d. Operators need spaces around them
after a bare word: ~u a|b is the URL regex a|b.
Request-only addons evaluate filters before the response exists, so ~s, ~c
and the response matchers are false there, as in mitmproxy. A body matcher can only be decided
once its body has been buffered. matches(org.microproxy.extras.FlowFilter.Flow) counts an unknown body as not matching;
mayMatch(org.microproxy.extras.FlowFilter.Flow) tells whether the filter could still match once the bodies are known, which
is how the addons buffer only the exchanges a filter might select.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn exchange as filters see it: the request, the response once there is one, and the bodies when they have been buffered. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FlowFilterThe filter that matches every exchange (~all). -
Method Summary
Modifier and TypeMethodDescriptionReturns the expression this filter was parsed from.static FlowFilter.Flowflow(HttpRequest request, String url, HttpResponse response) A view of an exchange for filters.booleanmatches(FlowFilter.Flow flow) Whetherflowmatches.booleanmayMatch(FlowFilter.Flow flow) Whetherflowcould match once the bodies that are not available yet are known: false only when the parts already known rule a match out.static FlowFilterParses a filter expression.static List<FlowFilter.Flow> queryDecoded(FlowFilter.Flow flow) flowas URL rules see it with the query of its normalized URL decoded, in each way an origin may decode it: escapes as UTF-8 with+kept and with+as a space, each also with the query delimiters& = # ;left escaped (so[^&]*does not stop at a decoded%26the origin reads inside one value).toString()booleanReturns whether the expression looks at the request body (~b,~bq).booleanReturns whether the expression looks at the response body (~b,~bs).booleanusesUrl()Returns whether the expression has a URL rule (~uor a bare regex).
-
Field Details
-
ALL
The filter that matches every exchange (~all).
-
-
Method Details
-
parse
Parses a filter expression.- Parameters:
expression- the expression, such as~d example.com & !~m GET- Returns:
- the parsed filter
- Throws:
IllegalArgumentException- if the expression is empty or invalid
-
expression
Returns the expression this filter was parsed from.- Returns:
- the expression this filter was parsed from
-
matches
Whetherflowmatches. Body matchers whose body is not available do not match.- Parameters:
flow- the exchange to test- Returns:
- whether the exchange matches
-
mayMatch
Whetherflowcould match once the bodies that are not available yet are known: false only when the parts already known rule a match out.- Parameters:
flow- the exchange to test, perhaps without its bodies- Returns:
- whether the exchange might match
-
usesRequestBody
public boolean usesRequestBody()Returns whether the expression looks at the request body (~b,~bq).- Returns:
- whether the expression looks at the request body (
~b,~bq)
-
usesUrl
public boolean usesUrl()Returns whether the expression has a URL rule (~uor a bare regex).- Returns:
- whether the expression has a URL rule (
~uor a bare regex)
-
usesResponseBody
public boolean usesResponseBody()Returns whether the expression looks at the response body (~b,~bs).- Returns:
- whether the expression looks at the response body (
~b,~bs)
-
toString
-
flow
A view of an exchange for filters. A body is available when its message is aFullHttpMessage(buffered) or declares no body; it is decoded (gzip, deflate, ...) only when a body matcher asks for it, and used as received if it cannot be decoded.- Parameters:
request- the requesturl- the absolute URL of the requestresponse- the response, or null before there is one- Returns:
- a view of the exchange
-
queryDecoded
flowas URL rules see it with the query of its normalized URL decoded, in each way an origin may decode it: escapes as UTF-8 with+kept and with+as a space, each also with the query delimiters& = # ;left escaped (so[^&]*does not stop at a decoded%26the origin reads inside one value). A form with a decoded line terminator is offered twice, for URL rules with.crossing it and stopping at it. Forms equal to the normalized URL or to each other are left out, so the list is empty when decoding changes nothing. Origins decode query values, so?file=%2Ffiles%2Fxis?file=/files/xto them;BlockListblocks when a rule matches the normalized URL or any of these forms. Only URL rules see the difference.- Parameters:
flow- the exchange- Returns:
- the exchange with its query decoded for URL rules, one flow per distinct form
-