Package org.openqa.selenium.remote.http
Interface Filter
-
- All Superinterfaces:
java.util.function.Function<HttpHandler,HttpHandler>
- All Known Implementing Classes:
AddSeleniumUserAgent
,DumpHttpExchangeFilter
,RetryRequest
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Filter extends java.util.function.Function<HttpHandler,HttpHandler>
Can be wrapped around anHttpHandler
in order to either modify incomingHttpRequest
s or outgoingHttpResponse
s using the well-known "Filter" pattern. This is very similar to the Servlet spec'sjavax.servlet.Filter
, but takes advantage of lambdas:Filter filter = next -> { return req -> { req.addHeader("cheese", "brie"); HttpResponse res = next.apply(req); res.addHeader("vegetable", "peas"); return res; }; }
Because each filter returns an
HttpHandler
, it's easy to do processing before, or after each request, as well as short-circuit things if necessary.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default HttpHandler
andFinally(HttpHandler end)
default Routable
andFinally(Routable end)
default Filter
andThen(Filter next)
-
-
-
Method Detail
-
andFinally
default HttpHandler andFinally(HttpHandler end)
-
-