public class BrowserMobProxyServer extends Object implements BrowserMobProxy
BrowserMobProxy.| Modifier and Type | Field and Description |
|---|---|
static String |
VIA_HEADER_ALIAS
The default pseudonym to use when adding the Via header to proxied requests.
|
| Constructor and Description |
|---|
BrowserMobProxyServer() |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Like
BrowserMobProxy.stop(), shuts down the proxy server and no longer accepts incoming connections, but does not wait for any existing
network traffic to cease. |
protected void |
addBrowserMobFilters()
Adds the basic browsermob-proxy filters, except for the relatively-expensive HAR capture filter.
|
void |
addFirstHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
Adds a new filter factory (request/response interceptor) to the beginning of the HttpFilters chain.
|
protected void |
addHarCaptureFilter()
Enables the HAR capture filter if it has not already been enabled.
|
void |
addHeader(String name,
String value)
Adds a new HTTP header to every request.
|
void |
addHeaders(Map<String,String> headers)
Adds the specified HTTP headers to every request.
|
void |
addHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory) |
void |
addLastHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
Adds a new filter factory (request/response interceptor) to the end of the HttpFilters chain.
|
void |
addRequestFilter(RequestFilter filter)
Note: The current implementation of this method forces a maximum request size of 2 MiB.
|
void |
addResponseFilter(ResponseFilter filter)
Note: The current implementation of this method forces a maximum response size of 2 MiB.
|
void |
addWhitelistPattern(String urlPattern)
Adds a URL-matching regular expression to an existing whitelist.
|
void |
autoAuthorization(String domain,
String username,
String password,
AuthType authType)
Enables automatic authorization for the specified domain and auth type.
|
void |
blacklistRequests(String pattern,
int responseCode)
Adds a URL-matching regular expression to the blacklist.
|
void |
blacklistRequests(String pattern,
int responseCode,
String method)
Adds a URL-matching regular expression to the blacklist.
|
void |
chainedProxyAuthorization(String username,
String password,
AuthType authType)
Enables chained proxy authorization using the Proxy-Authorization header described in RFC 7235, section 4.4 (https://tools.ietf.org/html/rfc7235#section-4.4).
|
void |
clearBlacklist()
Clears any existing blacklist.
|
void |
clearRewriteRules()
Clears all existing rewrite rules.
|
void |
disableHarCaptureTypes(CaptureType... captureTypes)
Disables the specified HAR capture types.
|
void |
disableHarCaptureTypes(Set<CaptureType> captureTypes)
Disables the specified HAR capture types.
|
void |
disableWhitelist()
Clears any existing whitelist and disables whitelisting.
|
void |
enableEmptyWhitelist(int statusCode)
Enables the whitelist, but with no matching URLs.
|
void |
enableHarCaptureTypes(CaptureType... captureTypes)
Enables the specified HAR capture types.
|
void |
enableHarCaptureTypes(Set<CaptureType> captureTypes)
Enables the specified HAR capture types.
|
Har |
endHar()
Stops capturing traffic in the HAR.
|
void |
endPage() |
Map<String,String> |
getAllHeaders()
Returns all headers previously added with
BrowserMobProxy.addHeader(String name, String value). |
Collection<BlacklistEntry> |
getBlacklist()
Returns all blacklist entries currently in effect.
|
InetSocketAddress |
getChainedProxy()
Returns the address and port of the upstream proxy.
|
InetAddress |
getClientBindAddress()
Returns the address of the network interface on which the proxy is listening for client connections.
|
HarPage |
getCurrentHarPage() |
List<org.littleshoot.proxy.HttpFiltersSource> |
getFilterFactories() |
Har |
getHar()
Retrieves the current HAR.
|
EnumSet<CaptureType> |
getHarCaptureTypes() |
AdvancedHostResolver |
getHostNameResolver()
Returns the current host name resolver.
|
int |
getPort()
Returns the actual port on which the proxy is listening for client connections.
|
long |
getReadBandwidthLimit()
Returns the current bandwidth limit for reading, in bytes per second.
|
Map<String,String> |
getRewriteRules()
Returns all rewrite rules currently in effect.
|
InetAddress |
getServerBindAddress()
Returns the address address of the network interface the proxy will use to initiate upstream connections.
|
int |
getWhitelistStatusCode()
Returns the status code returned for all URLs that do not match the whitelist.
|
Collection<String> |
getWhitelistUrls()
Returns the URL-matching regular expressions currently in effect.
|
long |
getWriteBandwidthLimit()
Returns the current bandwidth limit for writing, in bytes per second.
|
boolean |
isMitmDisabled() |
boolean |
isStarted()
Returns true if the proxy is started and listening for connections, otherwise false.
|
boolean |
isStopped() |
boolean |
isWhitelistEnabled()
Returns true if the whitelist is enabled, otherwise false.
|
Har |
newHar()
Starts a new HAR file with the default page name (see
BrowserMobProxy.newPage(). |
Har |
newHar(String initialPageRef)
Starts a new HAR file with the specified initialPageRef as the page name and page title.
|
Har |
newHar(String initialPageRef,
String initialPageTitle)
Starts a new HAR file with the specified page name and page title.
|
Har |
newPage()
Starts a new HAR page using the default page naming convention.
|
Har |
newPage(String pageRef)
Starts a new HAR page using the specified pageRef as the page name and the page title.
|
Har |
newPage(String pageRef,
String pageTitle)
Starts a new HAR page using the specified pageRef as the page name and the pageTitle as the page title.
|
void |
removeAllHeaders()
Removes all headers previously added with
BrowserMobProxy.addHeader(String name, String value). |
void |
removeHeader(String name)
Removes a header previously added with
BrowserMobProxy.addHeader(String name, String value). |
void |
removeRewriteRule(String urlPattern)
Removes an existing rewrite rule whose urlPattern matches the specified pattern.
|
void |
rewriteUrl(String pattern,
String replace)
Adds a rewrite rule for the specified URL-matching regular expression.
|
void |
rewriteUrls(Map<String,String> rewriteRules)
Replaces existing rewrite rules with the specified patterns and replacement expressions.
|
void |
setBlacklist(Collection<BlacklistEntry> blacklist)
Replaces any existing blacklist with the specified blacklist.
|
void |
setChainedProxy(InetSocketAddress chainedProxyAddress)
Instructs this proxy to route traffic through an upstream proxy.
|
void |
setChainedProxyManager(org.littleshoot.proxy.ChainedProxyManager chainedProxyManager)
Allows access to the LittleProxy
ChainedProxyManager for fine-grained control of the chained proxies. |
void |
setConnectTimeout(int connectTimeout,
TimeUnit timeUnit)
Maximum amount of time to wait to establish a connection to a remote server.
|
void |
setHarCaptureTypes(CaptureType... captureTypes)
Sets the data types that will be captured in the HAR file for future requests.
|
void |
setHarCaptureTypes(Set<CaptureType> harCaptureSettings)
Sets the data types that will be captured in the HAR file for future requests.
|
void |
setHostNameResolver(AdvancedHostResolver resolver)
Sets the resolver that will be used to look up host names.
|
void |
setIdleConnectionTimeout(int idleConnectionTimeout,
TimeUnit timeUnit)
The LittleProxy implementation only allows idle connection timeouts to be specified in seconds.
|
void |
setLatency(long latency,
TimeUnit timeUnit)
The minimum amount of time that will elapse between the time the proxy begins receiving a response from the server and the time the
proxy begins sending the response to the client.
|
void |
setMitmDisabled(boolean mitmDisabled)
Completely disables MITM for this proxy server.
|
void |
setMitmManager(org.littleshoot.proxy.MitmManager mitmManager)
Sets the MITM manager, which is responsible for generating forged SSL certificates to present to clients.
|
void |
setReadBandwidthLimit(long bytesPerSecond)
Sets the maximum bandwidth to consume when reading server responses.
|
void |
setRequestTimeout(int requestTimeout,
TimeUnit timeUnit)
Maximum amount of time to wait for an HTTP response from the remote server after the request has been sent in its entirety.
|
void |
setThreadPoolConfiguration(org.littleshoot.proxy.impl.ThreadPoolConfiguration threadPoolConfiguration)
Configures the Netty thread pool used by the LittleProxy back-end.
|
void |
setTrustAllServers(boolean trustAllServers)
Disables verification of all upstream servers' SSL certificates.
|
void |
setTrustSource(TrustSource trustSource)
Sets the
TrustSource that contains trusted root certificate authorities that will be used to validate
upstream servers' certificates. |
void |
setUseEcc(boolean useEcc) |
void |
setWriteBandwidthLimit(long bytesPerSecond)
Sets the maximum bandwidth to consume when sending requests to servers.
|
void |
start()
Starts the proxy on port 0 (a JVM-selected open port).
|
void |
start(int port)
Starts the proxy on the specified port.
|
void |
start(int port,
InetAddress bindAddress)
Starts the proxy on the specified port.
|
void |
start(int port,
InetAddress clientBindAddress,
InetAddress serverBindAddress)
Starts the proxy on the specified port.
|
void |
stop()
Stops accepting new client connections and initiates a graceful shutdown of the proxy server, waiting up to 5 seconds for network
traffic to stop.
|
protected void |
stop(boolean graceful) |
void |
stopAutoAuthorization(String domain)
Stops automatic authorization for the specified domain.
|
boolean |
waitForQuiescence(long quietPeriod,
long timeout,
TimeUnit timeUnit)
Waits for existing network traffic to stop, and for the specified quietPeriod to elapse.
|
void |
whitelistRequests(Collection<String> urlPatterns,
int statusCode)
Whitelists URLs matching the specified regular expression patterns.
|
void |
whitelistRequests(String[] patterns,
int responseCode)
Whitelist the specified request patterns, returning the specified responseCode for non-whitelisted
requests.
|
public static final String VIA_HEADER_ALIAS
public void start(int port,
InetAddress clientBindAddress,
InetAddress serverBindAddress)
BrowserMobProxystart in interface BrowserMobProxyport - port to listen onclientBindAddress - address of the network interface on which the proxy will listen for connectionsserverBindAddress - address of the network interface on which the proxy will connect to upstream serverspublic boolean isStarted()
BrowserMobProxyisStarted in interface BrowserMobProxypublic void start(int port)
BrowserMobProxystart in interface BrowserMobProxyport - port to listen onpublic void start(int port,
InetAddress bindAddress)
BrowserMobProxystart in interface BrowserMobProxyport - port to listen onbindAddress - address of the network interface on which the proxy will listen for connections and also attempt to connect to upstream servers.public void start()
BrowserMobProxystart in interface BrowserMobProxypublic void stop()
BrowserMobProxystop in interface BrowserMobProxypublic void abort()
BrowserMobProxyBrowserMobProxy.stop(), shuts down the proxy server and no longer accepts incoming connections, but does not wait for any existing
network traffic to cease. Any existing connections to clients or to servers may be force-killed immediately.
If the proxy was previously stopped or aborted, this method has no effect.abort in interface BrowserMobProxyprotected void stop(boolean graceful)
public InetAddress getClientBindAddress()
BrowserMobProxygetClientBindAddress in interface BrowserMobProxypublic int getPort()
BrowserMobProxygetPort in interface BrowserMobProxypublic InetAddress getServerBindAddress()
BrowserMobProxygetServerBindAddress in interface BrowserMobProxypublic Har getHar()
BrowserMobProxygetHar in interface BrowserMobProxypublic Har newHar()
BrowserMobProxyBrowserMobProxy.newPage(). Enables HAR capture if it was not previously enabled.newHar in interface BrowserMobProxypublic Har newHar(String initialPageRef)
BrowserMobProxynewHar in interface BrowserMobProxyinitialPageRef - initial page name of the new HAR filepublic Har newHar(String initialPageRef, String initialPageTitle)
BrowserMobProxynewHar in interface BrowserMobProxyinitialPageRef - initial page name of the new HAR fileinitialPageTitle - initial page title of the new HAR filepublic void setHarCaptureTypes(Set<CaptureType> harCaptureSettings)
BrowserMobProxyCaptureType data types. CaptureType provides several
convenience methods to retrieve commonly-used capture settings.
Note: HAR capture must still be explicitly enabled via BrowserMobProxy.newHar() or BrowserMobProxy.newHar(String) to begin capturing
any request and response contents.setHarCaptureTypes in interface BrowserMobProxyharCaptureSettings - HAR data types to capturepublic void setHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxyCaptureType data types. CaptureType provides several
convenience methods to retrieve commonly-used capture settings.
Note: HAR capture must still be explicitly enabled via BrowserMobProxy.newHar() or BrowserMobProxy.newHar(String) to begin capturing
any request and response contents.setHarCaptureTypes in interface BrowserMobProxycaptureTypes - HAR data types to capturepublic EnumSet<CaptureType> getHarCaptureTypes()
getHarCaptureTypes in interface BrowserMobProxypublic void enableHarCaptureTypes(Set<CaptureType> captureTypes)
BrowserMobProxyenableHarCaptureTypes in interface BrowserMobProxycaptureTypes - capture types to enablepublic void enableHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxyenableHarCaptureTypes in interface BrowserMobProxycaptureTypes - capture types to enablepublic void disableHarCaptureTypes(Set<CaptureType> captureTypes)
BrowserMobProxydisableHarCaptureTypes in interface BrowserMobProxycaptureTypes - capture types to disablepublic void disableHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxydisableHarCaptureTypes in interface BrowserMobProxycaptureTypes - capture types to disablepublic Har newPage()
BrowserMobProxyBrowserMobProxy.newHar() or BrowserMobProxy.newHar(String) is called, and increments on every subsequent call to BrowserMobProxy.newPage() or
BrowserMobProxy.newHar(String). Populates the HarPageTimings.onLoad value based on the amount of time
the current page has been captured.newPage in interface BrowserMobProxypublic Har newPage(String pageRef)
BrowserMobProxyHarPageTimings.onLoad value based on the amount of time the current page has been captured.newPage in interface BrowserMobProxypageRef - name of the new pagepublic Har newPage(String pageRef, String pageTitle)
BrowserMobProxyHarPageTimings.onLoad value based on the amount of time the current page has been captured.newPage in interface BrowserMobProxypageRef - name of the new pagepageTitle - title of the new pagepublic Har endHar()
BrowserMobProxyHarPageTimings.onLoad value for the current page
based on the amount of time it has been captured.endHar in interface BrowserMobProxypublic void setReadBandwidthLimit(long bytesPerSecond)
BrowserMobProxysetReadBandwidthLimit in interface BrowserMobProxybytesPerSecond - maximum bandwidth, in bytes per secondpublic long getReadBandwidthLimit()
BrowserMobProxygetReadBandwidthLimit in interface BrowserMobProxypublic void setWriteBandwidthLimit(long bytesPerSecond)
BrowserMobProxysetWriteBandwidthLimit in interface BrowserMobProxybytesPerSecond - maximum bandwidth, in bytes per secondpublic long getWriteBandwidthLimit()
BrowserMobProxygetWriteBandwidthLimit in interface BrowserMobProxypublic void endPage()
public void addHeaders(Map<String,String> headers)
BrowserMobProxyaddHeaders in interface BrowserMobProxyheaders - Map<header name, header value> to append to every request.public void setLatency(long latency,
TimeUnit timeUnit)
BrowserMobProxysetLatency in interface BrowserMobProxylatency - minimum latency, or 0 for no minimumtimeUnit - TimeUnit for the latencypublic void autoAuthorization(String domain, String username, String password, AuthType authType)
BrowserMobProxyautoAuthorization in interface BrowserMobProxydomain - domain automatically send authorization information tousername - authorization usernamepassword - authorization passwordauthType - authorization typepublic void stopAutoAuthorization(String domain)
BrowserMobProxystopAutoAuthorization in interface BrowserMobProxydomain - domain to stop automatically sending authorization information topublic void chainedProxyAuthorization(String username, String password, AuthType authType)
BrowserMobProxyAuthType.BASIC authentication is supported.chainedProxyAuthorization in interface BrowserMobProxyusername - the username to use to authenticate with the chained proxypassword - the password to use to authenticate with the chained proxyauthType - the auth type to use (currently, must be BASIC)public void setConnectTimeout(int connectTimeout,
TimeUnit timeUnit)
BrowserMobProxysetConnectTimeout in interface BrowserMobProxyconnectTimeout - maximum time to wait to establish a connection to a server, or 0 to wait indefinitelytimeUnit - TimeUnit for the connectionTimeoutpublic void setIdleConnectionTimeout(int idleConnectionTimeout,
TimeUnit timeUnit)
setIdleConnectionTimeout in interface BrowserMobProxyidleConnectionTimeout - maximum time to allow a connection to remain idle, or 0 to wait indefinitely.timeUnit - TimeUnit for the idleConnectionTimeoutpublic void setRequestTimeout(int requestTimeout,
TimeUnit timeUnit)
BrowserMobProxysetRequestTimeout in interface BrowserMobProxyrequestTimeout - maximum time to wait for an HTTP response, or 0 to wait indefinitelytimeUnit - TimeUnit for the requestTimeoutpublic void rewriteUrl(String pattern, String replace)
BrowserMobProxyPattern).
The replacementExpression may consist of capture groups specified in the urlPattern, denoted
by a $ (see Matcher.appendReplacement(StringBuffer, String).
For HTTP requests (not HTTPS), if the hostname and/or port is changed as a result of a rewrite rule, the Host header of the request will be modified
to reflect the updated hostname/port. For HTTPS requests, the host and port cannot be changed by rewrite rules
(use BrowserMobProxy.getHostNameResolver() and AdvancedHostResolver.remapHost(String, String) to direct HTTPS requests
to a different host).
Note: The rewriting applies to the entire URL, including scheme (http:// or https://), hostname/address, port, and query string. Note that this means
a urlPattern of "http://www\.website\.com/page" will NOT match http://www.website.com:80/page.
For example, the following rewrite rule:
proxy.rewriteUrl("http://www\\.(yahoo|bing)\\.com/\\?(\\w+)=(\\w+)", "http://www.google.com/?originalDomain=$1&$2=$3");
will match an HTTP request (but not HTTPS!) to www.yahoo.com or www.bing.com with exactly 1 query parameter,
and replace it with a call to www.google.com with an 'originalDomain' query parameter, as well as the original query parameter.
When applied to the URL:
http://www.yahoo.com?theFirstParam=someValue
will result in the proxy making a request to:
http://www.google.com?originalDomain=yahoo&theFirstParam=someValue
When applied to the URL:
http://www.bing.com?anotherParam=anotherValue
will result in the proxy making a request to:
http://www.google.com?originalDomain=bing&anotherParam=anotherValuerewriteUrl in interface BrowserMobProxypattern - URL-matching regular expressionreplace - an expression, which may optionally contain capture groups, which will replace any URL which matches urlPatternpublic void rewriteUrls(Map<String,String> rewriteRules)
BrowserMobProxyBrowserMobProxy.rewriteUrl(String, String) for details on the format of the rewrite rules.rewriteUrls in interface BrowserMobProxyrewriteRules - Map<urlPattern, replacementExpression>public void clearRewriteRules()
BrowserMobProxyclearRewriteRules in interface BrowserMobProxypublic void blacklistRequests(String pattern, int responseCode)
BrowserMobProxyblacklistRequests in interface BrowserMobProxypattern - URL-matching regular expression to blacklistresponseCode - HTTP status code to returnpublic void blacklistRequests(String pattern, int responseCode, String method)
BrowserMobProxyBrowserMobProxy.blacklistRequests(String, int) for details on the URL the urlPattern will match.blacklistRequests in interface BrowserMobProxypattern - URL-matching regular expression to blacklistresponseCode - HTTP status code to returnmethod - regular expression matching a request's HTTP methodpublic void setBlacklist(Collection<BlacklistEntry> blacklist)
BrowserMobProxysetBlacklist in interface BrowserMobProxyblacklist - new blacklist entriespublic Collection<BlacklistEntry> getBlacklist()
BrowserMobProxygetBlacklist in interface BrowserMobProxypublic boolean isWhitelistEnabled()
BrowserMobProxyisWhitelistEnabled in interface BrowserMobProxypublic Collection<String> getWhitelistUrls()
BrowserMobProxygetWhitelistUrls in interface BrowserMobProxypublic int getWhitelistStatusCode()
BrowserMobProxygetWhitelistStatusCode in interface BrowserMobProxypublic void clearBlacklist()
BrowserMobProxyclearBlacklist in interface BrowserMobProxypublic void whitelistRequests(Collection<String> urlPatterns, int statusCode)
BrowserMobProxywhitelistRequests in interface BrowserMobProxyurlPatterns - URL-matching regular expressions to whitelist; null or an empty collection will enable an empty whiteliststatusCode - HTTP status code to return to clients when a URL matches a patternpublic void addWhitelistPattern(String urlPattern)
BrowserMobProxyaddWhitelistPattern in interface BrowserMobProxyurlPattern - URL-matching regular expressions to whitelistpublic void whitelistRequests(String[] patterns, int responseCode)
patterns - regular expression strings matching URL patterns to whitelist. if empty or null,
the whitelist will be enabled but will not match any URLs.responseCode - the HTTP response code to return for non-whitelisted requestspublic void enableEmptyWhitelist(int statusCode)
BrowserMobProxyenableEmptyWhitelist in interface BrowserMobProxystatusCode - HTTP status code to return to clients on all requestspublic void disableWhitelist()
BrowserMobProxydisableWhitelist in interface BrowserMobProxypublic void addHeader(String name, String value)
BrowserMobProxyaddHeader in interface BrowserMobProxyname - name of the header to addvalue - new header's valuepublic void removeHeader(String name)
BrowserMobProxyBrowserMobProxy.addHeader(String name, String value).removeHeader in interface BrowserMobProxyname - previously-added header's namepublic void removeAllHeaders()
BrowserMobProxyBrowserMobProxy.addHeader(String name, String value).removeAllHeaders in interface BrowserMobProxypublic Map<String,String> getAllHeaders()
BrowserMobProxyBrowserMobProxy.addHeader(String name, String value).getAllHeaders in interface BrowserMobProxyMap<header name, header value>public void setHostNameResolver(AdvancedHostResolver resolver)
BrowserMobProxyChainedHostResolver.setHostNameResolver in interface BrowserMobProxyresolver - host name resolverpublic AdvancedHostResolver getHostNameResolver()
BrowserMobProxygetHostNameResolver in interface BrowserMobProxypublic boolean waitForQuiescence(long quietPeriod,
long timeout,
TimeUnit timeUnit)
BrowserMobProxywaitForQuiescence in interface BrowserMobProxyquietPeriod - amount of time after which network traffic will be considered "stopped"timeout - maximum amount of time to wait for network traffic to stoptimeUnit - TimeUnit for the quietPeriod and timeoutpublic void setChainedProxy(InetSocketAddress chainedProxyAddress)
setChainedProxyManager(ChainedProxyManager) will supersede any value set by this method. A chained
proxy must be set before the proxy is started, though it can be changed after the proxy is started.setChainedProxy in interface BrowserMobProxychainedProxyAddress - address of the upstream proxypublic InetSocketAddress getChainedProxy()
BrowserMobProxygetChainedProxy in interface BrowserMobProxypublic void setChainedProxyManager(org.littleshoot.proxy.ChainedProxyManager chainedProxyManager)
ChainedProxyManager for fine-grained control of the chained proxies. To enable a single
chained proxy, BrowserMobProxy.setChainedProxy(InetSocketAddress) is generally more convenient.
Note: The chained proxy manager must be enabled before calling start().chainedProxyManager - chained proxy manager to enablepublic void setThreadPoolConfiguration(org.littleshoot.proxy.impl.ThreadPoolConfiguration threadPoolConfiguration)
ThreadPoolConfiguration for details.threadPoolConfiguration - thread pool configuration to usepublic void addFirstHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
BrowserMobProxyHttpFiltersSource.filterRequest(io.netty.handler.codec.http.HttpRequest, io.netty.channel.ChannelHandlerContext) method and returning an
HttpFilters instance (typically, a subclass of HttpFiltersAdapter).
To disable or bypass a filter on a per-request basis, the filterRequest() method may return null.addFirstHttpFilterFactory in interface BrowserMobProxyfilterFactory - factory to generate HttpFilterspublic void addLastHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
BrowserMobProxyHttpFiltersSource.filterRequest(io.netty.handler.codec.http.HttpRequest, io.netty.channel.ChannelHandlerContext) method and returning an
HttpFilters instance (typically, a subclass of HttpFiltersAdapter).
To disable or bypass a filter on a per-request basis, the filterRequest() method may return null.addLastHttpFilterFactory in interface BrowserMobProxyfilterFactory - factory to generate HttpFilterspublic void addResponseFilter(ResponseFilter filter)
HttpMessageContents), you may add the filter source
directly: addFirstHttpFilterFactory(new ResponseFilterAdapter.FilterSource(filter, bufferSizeInBytes));addResponseFilter in interface BrowserMobProxyfilter - filter instancepublic void addRequestFilter(RequestFilter filter)
HttpMessageContents), you may add the filter source
directly: addFirstHttpFilterFactory(new RequestFilterAdapter.FilterSource(filter, bufferSizeInBytes));addRequestFilter in interface BrowserMobProxyfilter - filter instancepublic Map<String,String> getRewriteRules()
BrowserMobProxygetRewriteRules in interface BrowserMobProxyMap<URL-matching regex, replacement expression>public void removeRewriteRule(String urlPattern)
BrowserMobProxyremoveRewriteRule in interface BrowserMobProxyurlPattern - rewrite rule pattern to removepublic boolean isStopped()
public HarPage getCurrentHarPage()
public void addHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
public List<org.littleshoot.proxy.HttpFiltersSource> getFilterFactories()
public void setMitmDisabled(boolean mitmDisabled)
throws IllegalStateException
BrowserMobProxysetMitmDisabled in interface BrowserMobProxymitmDisabled - when true, MITM capture will be disabledIllegalStateException - if the proxy is already startedpublic void setMitmManager(org.littleshoot.proxy.MitmManager mitmManager)
BrowserMobProxyImpersonatingMitmManager and ImpersonatingMitmManager.Builder
for details on customizing the root and server certificate generation.setMitmManager in interface BrowserMobProxymitmManager - MITM manager to usepublic void setTrustAllServers(boolean trustAllServers)
BrowserMobProxysetTrustAllServers in interface BrowserMobProxytrustAllServers - when true, disables upstream server certificate verificationpublic void setTrustSource(TrustSource trustSource)
BrowserMobProxyTrustSource that contains trusted root certificate authorities that will be used to validate
upstream servers' certificates. When null, disables certificate validation (see warning at BrowserMobProxy.setTrustAllServers(boolean)).setTrustSource in interface BrowserMobProxytrustSource - TrustSource containing root CAs, or null to disable upstream server validationpublic boolean isMitmDisabled()
public void setUseEcc(boolean useEcc)
protected void addBrowserMobFilters()
protected void addHarCaptureFilter()
Copyright © 2016. All rights reserved.