public class BrowserUpProxyServer extends java.lang.Object implements BrowserUpProxy
BrowserUpProxy.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
VIA_HEADER_ALIAS
The default pseudonym to use when adding the Via header to proxied requests.
|
| Constructor and Description |
|---|
BrowserUpProxyServer() |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Like
BrowserUpProxy.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 |
addBrowserUpFilters()
Adds the basic BrowserUp-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(java.lang.String name,
java.lang.String value)
Adds a new HTTP header to every request.
|
void |
addHeaders(java.util.Map<java.lang.String,java.lang.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(java.lang.String urlPattern)
Adds a URL-matching regular expression to an existing whitelist.
|
AssertionResult |
assertMostRecentUrlResponseTimeWithin(java.util.regex.Pattern url,
long time) |
void |
autoAuthorization(java.lang.String domain,
java.lang.String username,
java.lang.String password,
AuthType authType)
Enables automatic authorization for the specified domain and auth type.
|
void |
blacklistRequests(java.lang.String pattern,
int responseCode)
Adds a URL-matching regular expression to the blacklist.
|
void |
blacklistRequests(java.lang.String pattern,
int responseCode,
java.lang.String method)
Adds a URL-matching regular expression to the blacklist.
|
void |
chainedProxyAuthorization(java.lang.String username,
java.lang.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(java.util.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(java.util.Set<CaptureType> captureTypes)
Enables the specified HAR capture types.
|
Har |
endHar()
Stops capturing traffic in the HAR.
|
void |
endPage() |
java.util.Collection<HarEntry> |
findEntries(java.util.regex.Pattern url)
Search the entire log for entries whose request URL matches the given
url. |
java.util.Optional<HarEntry> |
findMostRecentEntry(java.util.regex.Pattern url)
Search the entire log for the most recent entry whose request URL matches the given
url. |
java.util.Map<java.lang.String,java.lang.String> |
getAllHeaders()
Returns all headers previously added with
BrowserUpProxy.addHeader(String name, String value). |
java.util.Collection<BlacklistEntry> |
getBlacklist()
Returns all blacklist entries currently in effect.
|
java.net.InetSocketAddress |
getChainedProxy()
Returns the address and port of the upstream proxy.
|
java.net.InetAddress |
getClientBindAddress()
Returns the address of the network interface on which the proxy is listening for client connections.
|
HarPage |
getCurrentHarPage() |
java.util.List<org.littleshoot.proxy.HttpFiltersSource> |
getFilterFactories() |
Har |
getHar()
Retrieves the current HAR.
|
java.util.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.
|
java.util.Map<java.lang.String,java.lang.String> |
getRewriteRules()
Returns all rewrite rules currently in effect.
|
java.net.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.
|
java.util.Collection<java.lang.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
BrowserUpProxy.newPage(). |
Har |
newHar(java.lang.String initialPageRef)
Starts a new HAR file with the specified initialPageRef as the page name and page title.
|
Har |
newHar(java.lang.String initialPageRef,
java.lang.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(java.lang.String pageRef)
Starts a new HAR page using the specified pageRef as the page name and the page title.
|
Har |
newPage(java.lang.String pageRef,
java.lang.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
BrowserUpProxy.addHeader(String name, String value). |
void |
removeHeader(java.lang.String name)
Removes a header previously added with
BrowserUpProxy.addHeader(String name, String value). |
void |
removeRewriteRule(java.lang.String urlPattern)
Removes an existing rewrite rule whose urlPattern matches the specified pattern.
|
void |
rewriteUrl(java.lang.String pattern,
java.lang.String replace)
Adds a rewrite rule for the specified URL-matching regular expression.
|
void |
rewriteUrls(java.util.Map<java.lang.String,java.lang.String> rewriteRules)
Replaces existing rewrite rules with the specified patterns and replacement expressions.
|
void |
setBlacklist(java.util.Collection<BlacklistEntry> blacklist)
Replaces any existing blacklist with the specified blacklist.
|
void |
setChainedProxy(java.net.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,
java.util.concurrent.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(java.util.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,
java.util.concurrent.TimeUnit timeUnit)
The LittleProxy implementation only allows idle connection timeouts to be specified in seconds.
|
void |
setLatency(long latency,
java.util.concurrent.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,
java.util.concurrent.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(com.browserup.bup.mitm.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,
java.net.InetAddress bindAddress)
Starts the proxy on the specified port.
|
void |
start(int port,
java.net.InetAddress clientBindAddress,
java.net.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(java.lang.String domain)
Stops automatic authorization for the specified domain.
|
boolean |
waitForQuiescence(long quietPeriod,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
Waits for existing network traffic to stop, and for the specified quietPeriod to elapse.
|
void |
whitelistRequests(java.util.Collection<java.lang.String> urlPatterns,
int statusCode)
Whitelists URLs matching the specified regular expression patterns.
|
void |
whitelistRequests(java.lang.String[] patterns,
int responseCode)
Whitelist the specified request patterns, returning the specified responseCode for non-whitelisted
requests.
|
public static final java.lang.String VIA_HEADER_ALIAS
public void start(int port,
java.net.InetAddress clientBindAddress,
java.net.InetAddress serverBindAddress)
BrowserUpProxystart in interface BrowserUpProxyport - 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()
BrowserUpProxyisStarted in interface BrowserUpProxypublic void start(int port)
BrowserUpProxystart in interface BrowserUpProxyport - port to listen onpublic void start(int port,
java.net.InetAddress bindAddress)
BrowserUpProxystart in interface BrowserUpProxyport - 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()
BrowserUpProxystart in interface BrowserUpProxypublic void stop()
BrowserUpProxystop in interface BrowserUpProxypublic void abort()
BrowserUpProxyBrowserUpProxy.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 BrowserUpProxyprotected void stop(boolean graceful)
public java.net.InetAddress getClientBindAddress()
BrowserUpProxygetClientBindAddress in interface BrowserUpProxypublic int getPort()
BrowserUpProxygetPort in interface BrowserUpProxypublic java.net.InetAddress getServerBindAddress()
BrowserUpProxygetServerBindAddress in interface BrowserUpProxypublic Har getHar()
BrowserUpProxygetHar in interface BrowserUpProxypublic Har newHar()
BrowserUpProxyBrowserUpProxy.newPage(). Enables HAR capture if it was not previously enabled.newHar in interface BrowserUpProxypublic Har newHar(java.lang.String initialPageRef)
BrowserUpProxynewHar in interface BrowserUpProxyinitialPageRef - initial page name of the new HAR filepublic Har newHar(java.lang.String initialPageRef, java.lang.String initialPageTitle)
BrowserUpProxynewHar in interface BrowserUpProxyinitialPageRef - initial page name of the new HAR fileinitialPageTitle - initial page title of the new HAR filepublic void setHarCaptureTypes(java.util.Set<CaptureType> harCaptureSettings)
BrowserUpProxyCaptureType data types. CaptureType provides several
convenience methods to retrieve commonly-used capture settings.
Note: HAR capture must still be explicitly enabled via BrowserUpProxy.newHar() or BrowserUpProxy.newHar(String) to begin capturing
any request and response contents.setHarCaptureTypes in interface BrowserUpProxyharCaptureSettings - HAR data types to capturepublic void setHarCaptureTypes(CaptureType... captureTypes)
BrowserUpProxyCaptureType data types. CaptureType provides several
convenience methods to retrieve commonly-used capture settings.
Note: HAR capture must still be explicitly enabled via BrowserUpProxy.newHar() or BrowserUpProxy.newHar(String) to begin capturing
any request and response contents.setHarCaptureTypes in interface BrowserUpProxycaptureTypes - HAR data types to capturepublic java.util.EnumSet<CaptureType> getHarCaptureTypes()
getHarCaptureTypes in interface BrowserUpProxypublic void enableHarCaptureTypes(java.util.Set<CaptureType> captureTypes)
BrowserUpProxyenableHarCaptureTypes in interface BrowserUpProxycaptureTypes - capture types to enablepublic void enableHarCaptureTypes(CaptureType... captureTypes)
BrowserUpProxyenableHarCaptureTypes in interface BrowserUpProxycaptureTypes - capture types to enablepublic void disableHarCaptureTypes(java.util.Set<CaptureType> captureTypes)
BrowserUpProxydisableHarCaptureTypes in interface BrowserUpProxycaptureTypes - capture types to disablepublic void disableHarCaptureTypes(CaptureType... captureTypes)
BrowserUpProxydisableHarCaptureTypes in interface BrowserUpProxycaptureTypes - capture types to disablepublic Har newPage()
BrowserUpProxyBrowserUpProxy.newHar() or BrowserUpProxy.newHar(String) is called, and increments on every subsequent call to BrowserUpProxy.newPage() or
BrowserUpProxy.newHar(String). Populates the HarPageTiming.onLoad value based on the amount of time
the current page has been captured.newPage in interface BrowserUpProxypublic Har newPage(java.lang.String pageRef)
BrowserUpProxyHarPageTiming.onLoad value based on the amount of time the current page has been captured.newPage in interface BrowserUpProxypageRef - name of the new pagepublic Har newPage(java.lang.String pageRef, java.lang.String pageTitle)
BrowserUpProxyHarPageTiming.onLoad value based on the amount of time the current page has been captured.newPage in interface BrowserUpProxypageRef - name of the new pagepageTitle - title of the new pagepublic Har endHar()
BrowserUpProxyHarPageTiming.onLoad value for the current page
based on the amount of time it has been captured.endHar in interface BrowserUpProxypublic void setReadBandwidthLimit(long bytesPerSecond)
BrowserUpProxysetReadBandwidthLimit in interface BrowserUpProxybytesPerSecond - maximum bandwidth, in bytes per secondpublic long getReadBandwidthLimit()
BrowserUpProxygetReadBandwidthLimit in interface BrowserUpProxypublic void setWriteBandwidthLimit(long bytesPerSecond)
BrowserUpProxysetWriteBandwidthLimit in interface BrowserUpProxybytesPerSecond - maximum bandwidth, in bytes per secondpublic long getWriteBandwidthLimit()
BrowserUpProxygetWriteBandwidthLimit in interface BrowserUpProxypublic void endPage()
public void addHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
BrowserUpProxyaddHeaders in interface BrowserUpProxyheaders - Map<header name, header value> to append to every request.public void setLatency(long latency,
java.util.concurrent.TimeUnit timeUnit)
BrowserUpProxysetLatency in interface BrowserUpProxylatency - minimum latency, or 0 for no minimumtimeUnit - TimeUnit for the latencypublic void autoAuthorization(java.lang.String domain,
java.lang.String username,
java.lang.String password,
AuthType authType)
BrowserUpProxyautoAuthorization in interface BrowserUpProxydomain - domain automatically send authorization information tousername - authorization usernamepassword - authorization passwordauthType - authorization typepublic void stopAutoAuthorization(java.lang.String domain)
BrowserUpProxystopAutoAuthorization in interface BrowserUpProxydomain - domain to stop automatically sending authorization information topublic void chainedProxyAuthorization(java.lang.String username,
java.lang.String password,
AuthType authType)
BrowserUpProxyAuthType.BASIC authentication is supported.chainedProxyAuthorization in interface BrowserUpProxyusername - 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,
java.util.concurrent.TimeUnit timeUnit)
BrowserUpProxysetConnectTimeout in interface BrowserUpProxyconnectTimeout - maximum time to wait to establish a connection to a server, or 0 to wait indefinitelytimeUnit - TimeUnit for the connectionTimeoutpublic void setIdleConnectionTimeout(int idleConnectionTimeout,
java.util.concurrent.TimeUnit timeUnit)
setIdleConnectionTimeout in interface BrowserUpProxyidleConnectionTimeout - maximum time to allow a connection to remain idle, or 0 to wait indefinitely.timeUnit - TimeUnit for the idleConnectionTimeoutpublic void setRequestTimeout(int requestTimeout,
java.util.concurrent.TimeUnit timeUnit)
BrowserUpProxysetRequestTimeout in interface BrowserUpProxyrequestTimeout - maximum time to wait for an HTTP response, or 0 to wait indefinitelytimeUnit - TimeUnit for the requestTimeoutpublic void rewriteUrl(java.lang.String pattern,
java.lang.String replace)
BrowserUpProxyPattern).
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 BrowserUpProxy.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 BrowserUpProxypattern - URL-matching regular expressionreplace - an expression, which may optionally contain capture groups, which will replace any URL which matches urlPatternpublic void rewriteUrls(java.util.Map<java.lang.String,java.lang.String> rewriteRules)
BrowserUpProxyBrowserUpProxy.rewriteUrl(String, String) for details on the format of the rewrite rules.rewriteUrls in interface BrowserUpProxyrewriteRules - Map<urlPattern, replacementExpression>public void clearRewriteRules()
BrowserUpProxyclearRewriteRules in interface BrowserUpProxypublic void blacklistRequests(java.lang.String pattern,
int responseCode)
BrowserUpProxyblacklistRequests in interface BrowserUpProxypattern - URL-matching regular expression to blacklistresponseCode - HTTP status code to returnpublic void blacklistRequests(java.lang.String pattern,
int responseCode,
java.lang.String method)
BrowserUpProxyBrowserUpProxy.blacklistRequests(String, int) for details on the URL the urlPattern will match.blacklistRequests in interface BrowserUpProxypattern - URL-matching regular expression to blacklistresponseCode - HTTP status code to returnmethod - regular expression matching a request's HTTP methodpublic void setBlacklist(java.util.Collection<BlacklistEntry> blacklist)
BrowserUpProxysetBlacklist in interface BrowserUpProxyblacklist - new blacklist entriespublic java.util.Collection<BlacklistEntry> getBlacklist()
BrowserUpProxygetBlacklist in interface BrowserUpProxypublic boolean isWhitelistEnabled()
BrowserUpProxyisWhitelistEnabled in interface BrowserUpProxypublic java.util.Collection<java.lang.String> getWhitelistUrls()
BrowserUpProxygetWhitelistUrls in interface BrowserUpProxypublic int getWhitelistStatusCode()
BrowserUpProxygetWhitelistStatusCode in interface BrowserUpProxypublic void clearBlacklist()
BrowserUpProxyclearBlacklist in interface BrowserUpProxypublic void whitelistRequests(java.util.Collection<java.lang.String> urlPatterns,
int statusCode)
BrowserUpProxywhitelistRequests in interface BrowserUpProxyurlPatterns - 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(java.lang.String urlPattern)
BrowserUpProxyaddWhitelistPattern in interface BrowserUpProxyurlPattern - URL-matching regular expressions to whitelistpublic void whitelistRequests(java.lang.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)
BrowserUpProxyenableEmptyWhitelist in interface BrowserUpProxystatusCode - HTTP status code to return to clients on all requestspublic void disableWhitelist()
BrowserUpProxydisableWhitelist in interface BrowserUpProxypublic void addHeader(java.lang.String name,
java.lang.String value)
BrowserUpProxyaddHeader in interface BrowserUpProxyname - name of the header to addvalue - new header's valuepublic void removeHeader(java.lang.String name)
BrowserUpProxyBrowserUpProxy.addHeader(String name, String value).removeHeader in interface BrowserUpProxyname - previously-added header's namepublic void removeAllHeaders()
BrowserUpProxyBrowserUpProxy.addHeader(String name, String value).removeAllHeaders in interface BrowserUpProxypublic java.util.Map<java.lang.String,java.lang.String> getAllHeaders()
BrowserUpProxyBrowserUpProxy.addHeader(String name, String value).getAllHeaders in interface BrowserUpProxyMap<header name, header value>public void setHostNameResolver(AdvancedHostResolver resolver)
BrowserUpProxyChainedHostResolver.setHostNameResolver in interface BrowserUpProxyresolver - host name resolverpublic AdvancedHostResolver getHostNameResolver()
BrowserUpProxygetHostNameResolver in interface BrowserUpProxypublic boolean waitForQuiescence(long quietPeriod,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
BrowserUpProxywaitForQuiescence in interface BrowserUpProxyquietPeriod - 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(java.net.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 BrowserUpProxychainedProxyAddress - address of the upstream proxypublic java.net.InetSocketAddress getChainedProxy()
BrowserUpProxygetChainedProxy in interface BrowserUpProxypublic void setChainedProxyManager(org.littleshoot.proxy.ChainedProxyManager chainedProxyManager)
ChainedProxyManager for fine-grained control of the chained proxies. To enable a single
chained proxy, BrowserUpProxy.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)
BrowserUpProxyHttpFiltersSource.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 BrowserUpProxyfilterFactory - factory to generate HttpFilterspublic void addLastHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
BrowserUpProxyHttpFiltersSource.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 BrowserUpProxyfilterFactory - 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 BrowserUpProxyfilter - filter instancepublic void addRequestFilter(RequestFilter filter)
HttpMessageContents), you may add the filter source
directly: addFirstHttpFilterFactory(new RequestFilterAdapter.FilterSource(filter, bufferSizeInBytes));addRequestFilter in interface BrowserUpProxyfilter - filter instancepublic java.util.Map<java.lang.String,java.lang.String> getRewriteRules()
BrowserUpProxygetRewriteRules in interface BrowserUpProxyMap<URL-matching regex, replacement expression>public void removeRewriteRule(java.lang.String urlPattern)
BrowserUpProxyremoveRewriteRule in interface BrowserUpProxyurlPattern - rewrite rule pattern to removepublic boolean isStopped()
public HarPage getCurrentHarPage()
public void addHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
public java.util.List<org.littleshoot.proxy.HttpFiltersSource> getFilterFactories()
public void setMitmDisabled(boolean mitmDisabled)
throws java.lang.IllegalStateException
BrowserUpProxysetMitmDisabled in interface BrowserUpProxymitmDisabled - when true, MITM capture will be disabledjava.lang.IllegalStateException - if the proxy is already startedpublic void setMitmManager(org.littleshoot.proxy.MitmManager mitmManager)
BrowserUpProxyImpersonatingMitmManager and ImpersonatingMitmManager.Builder
for details on customizing the root and server certificate generation.setMitmManager in interface BrowserUpProxymitmManager - MITM manager to usepublic void setTrustAllServers(boolean trustAllServers)
BrowserUpProxysetTrustAllServers in interface BrowserUpProxytrustAllServers - when true, disables upstream server certificate verificationpublic void setTrustSource(com.browserup.bup.mitm.TrustSource trustSource)
BrowserUpProxyTrustSource that contains trusted root certificate authorities that will be used to validate
upstream servers' certificates. When null, disables certificate validation (see warning at BrowserUpProxy.setTrustAllServers(boolean)).setTrustSource in interface BrowserUpProxytrustSource - TrustSource containing root CAs, or null to disable upstream server validationpublic java.util.Optional<HarEntry> findMostRecentEntry(java.util.regex.Pattern url)
BrowserUpProxyurl.findMostRecentEntry in interface BrowserUpProxyurl - Regular expression match of URL to find.
URLs are formatted as: scheme://host:port/path?querystring.
Port is not included in the URL if it is the standard port for the scheme.
Fragments (example.com/#fragment) should not be included in the URL.
If more than one URL found, return the most recently requested URL.
Pattern examples:
- Match a URL with "http" or "https" protocol, "example.com" domain, and "/index.html" exact file path, with no query parameters:
"^(http|https)://example\\.com/index\\.html$"
- Match a URL with "http" protocol, "example.com" domain, "/customer" exact path, followed by any query string:
"^http://example\\.com/customer\\?.*"
- Match a URL with "http" protocol, "example.com" domain, "/products" path, and exactly 1 UUID query parameter named "id":
"^http://example\\.com/products\\?id=[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}$"HarEntry for the most recently requested URL matching the given url pattern.public java.util.Collection<HarEntry> findEntries(java.util.regex.Pattern url)
BrowserUpProxyurl.findEntries in interface BrowserUpProxyurl - Regular expression match of URL to find.
URLs are formatted as: scheme://host:port/path?querystring.
Port is not included in the URL if it is the standard port for the scheme.
Fragments (example.com/#fragment) should not be included in the URL.
If more than one URL found, use the most recently requested URL.
Pattern examples:
- Match a URL with "http" or "https" protocol, "example.com" domain, and "/index.html" exact file path, with no query parameters:
"^(http|https)://example\\.com/index\\.html$"
- Match a URL with "http" protocol, "example.com" domain, "/customer" exact path, followed by any query string:
"^http://example\\.com/customer\\?.*"
- Match a URL with "http" protocol, "example.com" domain, "/products" path, and exactly 1 UUID query parameter named "id":
"^http://example\\.com/products\\?id=[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}$"HarEntry for any requests whose URL matches the given url pattern,
or an empty list if none match.public AssertionResult assertMostRecentUrlResponseTimeWithin(java.util.regex.Pattern url, long time)
assertMostRecentUrlResponseTimeWithin in interface BrowserUpProxypublic boolean isMitmDisabled()
public void setUseEcc(boolean useEcc)
protected void addBrowserUpFilters()
protected void addHarCaptureFilter()