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) |
~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.toString()booleanReturns whether the expression looks at the request body (~b,~bq).booleanReturns whether the expression looks at the response body (~b,~bs).
-
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)
-
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
-