BrowserMobProxy
interface to preserve compatibility with future BrowserMob Proxy versions.@Deprecated public class ProxyServer extends Object implements LegacyProxyServer, BrowserMobProxy
LegacyProxyServer
interface that defines the BMP 2.0 contact, as well as the 2.1+ BrowserMobProxy
interface. Important: if
you are implementing new code, use the BrowserMobProxy
interface. The
LegacyProxyServer
interface is deprecated and will be removed in a future release.
BrowserMobProxy
operations are not supported and will be ignored:
BrowserMobProxy.getServerBindAddress()
and start(int, java.net.InetAddress, java.net.InetAddress)
- server bind addresses are not supportedBrowserMobProxy.stopAutoAuthorization(String)
Modifier and Type | Class and Description |
---|---|
static class |
ProxyServer.TimeoutException
Deprecated.
Exception thrown when waitForNetworkTrafficToStop does not successfully wait for network traffic to stop.
|
Modifier and Type | Field and Description |
---|---|
static String |
ALLOW_NATIVE_DNS_FALLBACK
Deprecated.
System property to allow fallback to the native Java hostname lookup mechanism when dnsjava (xbill) cannot resolve the hostname.
|
Constructor and Description |
---|
ProxyServer()
Deprecated.
|
ProxyServer(int port)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Deprecated.
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. |
void |
addFirstHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
Deprecated.
Adds a new filter factory (request/response interceptor) to the beginning of the HttpFilters chain.
|
void |
addHeader(String name,
String value)
Deprecated.
Adds a new HTTP header to every request.
|
void |
addHeaders(Map<String,String> headers)
Deprecated.
Adds the specified HTTP headers to every request.
|
void |
addLastHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
Deprecated.
Adds a new filter factory (request/response interceptor) to the end of the HttpFilters chain.
|
void |
addRequestFilter(RequestFilter filter)
Deprecated.
Adds a new RequestFilter that can be used to examine and manipulate the request before sending it to the server.
|
void |
addRequestInterceptor(org.apache.http.HttpRequestInterceptor i)
Deprecated.
|
void |
addRequestInterceptor(RequestInterceptor interceptor)
Deprecated.
|
void |
addResponseFilter(ResponseFilter filter)
Deprecated.
Adds a new ResponseFilter that can be used to examine and manipulate the response before sending it to the client.
|
void |
addResponseInterceptor(org.apache.http.HttpResponseInterceptor i)
Deprecated.
|
void |
addResponseInterceptor(ResponseInterceptor interceptor)
Deprecated.
|
void |
addWhitelistPattern(String urlPattern)
Deprecated.
Adds a URL-matching regular expression to an existing whitelist.
|
void |
autoAuthorization(String domain,
String username,
String password,
AuthType authType)
Deprecated.
Enables automatic authorization for the specified domain and auth type.
|
void |
autoBasicAuthorization(String domain,
String username,
String password)
Deprecated.
|
void |
blacklistRequests(String pattern,
int responseCode)
Deprecated.
Adds a URL-matching regular expression to the blacklist.
|
void |
blacklistRequests(String pattern,
int responseCode,
String method)
Deprecated.
Adds a URL-matching regular expression to the blacklist.
|
void |
cleanSslCertificates()
Deprecated.
|
void |
cleanup()
Deprecated.
|
void |
clearBlacklist()
Deprecated.
Clears any existing blacklist.
|
void |
clearDNSCache()
Deprecated.
|
void |
clearRewriteRules()
Deprecated.
Clears all existing rewrite rules.
|
void |
clearWhitelist()
Deprecated.
|
void |
disableHarCaptureTypes(CaptureType... captureTypes)
Deprecated.
Disables the specified HAR capture types.
|
void |
disableHarCaptureTypes(Set<CaptureType> captureTypes)
Deprecated.
Disables the specified HAR capture types.
|
void |
disableWhitelist()
Deprecated.
Clears any existing whitelist and disables whitelisting.
|
void |
enableEmptyWhitelist(int responseCode)
Deprecated.
Enables an empty whitelist, which will return the specified responseCode for all requests.
|
void |
enableHarCaptureTypes(CaptureType... captureTypes)
Deprecated.
Enables the specified HAR capture types.
|
void |
enableHarCaptureTypes(Set<CaptureType> captureTypes)
Deprecated.
Enables the specified HAR capture types.
|
Har |
endHar()
Deprecated.
Stops capturing traffic in the HAR.
|
void |
endPage()
Deprecated.
|
Map<String,String> |
getAllHeaders()
Deprecated.
Returns all headers previously added with
BrowserMobProxy.addHeader(String name, String value) . |
Collection<BlacklistEntry> |
getBlacklist()
Deprecated.
Returns all blacklist entries currently in effect.
|
List<BlacklistEntry> |
getBlacklistedRequests()
Deprecated.
use getBlacklistedUrls()
|
Collection<BlacklistEntry> |
getBlacklistedUrls()
Deprecated.
|
InetSocketAddress |
getChainedProxy()
Deprecated.
Returns the address and port of the upstream proxy.
|
InetAddress |
getClientBindAddress()
Deprecated.
Returns the address of the network interface on which the proxy is listening for client connections.
|
InetAddress |
getConnectableLocalHost()
Deprecated.
Return a plausible
InetAddress that other processes can use to
contact the proxy. |
Har |
getHar()
Deprecated.
Retrieves the current HAR.
|
EnumSet<CaptureType> |
getHarCaptureTypes()
Deprecated.
|
AdvancedHostResolver |
getHostNameResolver()
Deprecated.
Returns the current host name resolver.
|
InetAddress |
getLocalHost()
Deprecated.
Get the the InetAddress that the Proxy server binds to when it starts.
|
int |
getPort()
Deprecated.
Returns the actual port on which the proxy is listening for client connections.
|
Map<String,String> |
getRewriteRules()
Deprecated.
Returns all rewrite rules currently in effect.
|
InetAddress |
getServerBindAddress()
Deprecated.
Returns the address address of the network interface the proxy will use to initiate upstream connections.
|
StreamManager |
getStreamManager()
Deprecated.
|
List<Pattern> |
getWhitelistRequests()
Deprecated.
use getWhitelistUrls()
|
int |
getWhitelistResponseCode()
Deprecated.
|
int |
getWhitelistStatusCode()
Deprecated.
Returns the status code returned for all URLs that do not match the whitelist.
|
Collection<String> |
getWhitelistUrls()
Deprecated.
Returns the URL-matching regular expressions currently in effect.
|
boolean |
isStarted()
Deprecated.
Returns true if the proxy is started and listening for connections, otherwise false.
|
boolean |
isWhitelistEnabled()
Deprecated.
Returns true if the whitelist is enabled, otherwise false.
|
Har |
newHar()
Deprecated.
Starts a new HAR file with the default page name (see
BrowserMobProxy.newPage() . |
Har |
newHar(String initialPageRef)
Deprecated.
Starts a new HAR file with the specified initialPageRef as the page name and page title.
|
Har |
newHar(String initialPageRef,
String initialPageTitle)
Deprecated.
Starts a new HAR file with the specified page name and page title.
|
Har |
newPage()
Deprecated.
Starts a new HAR page using the default page naming convention.
|
Har |
newPage(String pageRef)
Deprecated.
Starts a new HAR page using the specified pageRef as the page name and the page title.
|
Har |
newPage(String pageRef,
String pageTitle)
Deprecated.
Starts a new HAR page using the specified pageRef as the page name and the pageTitle as the page title.
|
void |
remapHost(String source,
String target)
Deprecated.
|
void |
removeAllHeaders()
Deprecated.
Removes all headers previously added with
BrowserMobProxy.addHeader(String name, String value) . |
void |
removeHeader(String name)
Deprecated.
Removes a header previously added with
BrowserMobProxy.addHeader(String name, String value) . |
void |
removeRewriteRule(String urlPattern)
Deprecated.
Removes an existing rewrite rule whose urlPattern matches the specified pattern.
|
void |
rewriteUrl(String match,
String replace)
Deprecated.
Adds a rewrite rule for the specified URL-matching regular expression.
|
void |
rewriteUrls(Map<String,String> rewriteRules)
Deprecated.
Replaces existing rewrite rules with the specified patterns and replacement expressions.
|
org.openqa.selenium.Proxy |
seleniumProxy()
Deprecated.
|
void |
setBlacklist(Collection<BlacklistEntry> blacklist)
Deprecated.
Replaces any existing blacklist with the specified blacklist.
|
void |
setCaptureBinaryContent(boolean captureBinaryContent)
Deprecated.
|
void |
setCaptureContent(boolean captureContent)
Deprecated.
|
void |
setCaptureHeaders(boolean captureHeaders)
Deprecated.
|
void |
setChainedProxy(InetSocketAddress chainedProxyAddress)
Deprecated.
Sets an upstream proxy that this proxy will use to connect to external hosts.
|
void |
setConnectionTimeout(int connectionTimeout)
Deprecated.
|
void |
setConnectTimeout(int connectionTimeout,
TimeUnit timeUnit)
Deprecated.
Maximum amount of time to wait to establish a connection to a remote server.
|
void |
setDNSCacheTimeout(int timeout)
Deprecated.
|
void |
setDownstreamKbps(long downstreamKbps)
Deprecated.
|
void |
setHarCaptureTypes(CaptureType... captureTypes)
Deprecated.
Sets the data types that will be captured in the HAR file for future requests.
|
void |
setHarCaptureTypes(Set<CaptureType> captureTypes)
Deprecated.
Sets the data types that will be captured in the HAR file for future requests.
|
void |
setHostNameResolver(AdvancedHostResolver resolver)
Deprecated.
Sets the resolver that will be used to look up host names.
|
void |
setIdleConnectionTimeout(int idleConnectionTimeout,
TimeUnit timeUnit)
Deprecated.
Maximum amount of time to allow a connection to remain idle.
|
void |
setLatency(long latency)
Deprecated.
|
void |
setLatency(long latency,
TimeUnit timeUnit)
Deprecated.
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 |
setLocalHost(InetAddress localHost)
Deprecated.
|
void |
setMitmDisabled(boolean mitmDisabled)
Deprecated.
Completely disables MITM for this proxy server.
|
void |
setMitmManager(org.littleshoot.proxy.MitmManager mitmManager)
Deprecated.
Sets the MITM manager, which is responsible for generating forged SSL certificates to present to clients.
|
void |
setOptions(Map<String,String> options)
Deprecated.
|
void |
setPort(int port)
Deprecated.
|
void |
setReadBandwidthLimit(long bytesPerSecond)
Deprecated.
Sets the maximum bandwidth to consume when reading server responses.
|
void |
setRequestTimeout(int requestTimeout)
Deprecated.
|
void |
setRequestTimeout(int requestTimeout,
TimeUnit timeUnit)
Deprecated.
Maximum amount of time to wait for an HTTP response from the remote server after the request has been sent in its entirety.
|
void |
setRetryCount(int count)
Deprecated.
|
void |
setSocketOperationTimeout(int readTimeout)
Deprecated.
|
void |
setTrustAllServers(boolean trustAllServers)
Deprecated.
Disables verification of all upstream servers' SSL certificates.
|
void |
setTrustSource(TrustSource trustSource)
Deprecated.
Sets the
TrustSource that contains trusted root certificate authorities that will be used to validate
upstream servers' certificates. |
void |
setUpstreamKbps(long upstreamKbps)
Deprecated.
|
void |
setWriteBandwidthLimit(long bytesPerSecond)
Deprecated.
Sets the maximum bandwidth to consume when sending requests to servers.
|
void |
start()
Deprecated.
Starts the proxy on port 0 (a JVM-selected open port).
|
void |
start(int port)
Deprecated.
Starts the proxy on the specified port.
|
void |
start(int port,
InetAddress bindAddress)
Deprecated.
Starts the proxy on the specified port.
|
void |
start(int port,
InetAddress clientBindAddress,
InetAddress serverBindAddress)
Deprecated.
Starts the proxy on the specified port.
|
void |
stop()
Deprecated.
Stops accepting new client connections and initiates a graceful shutdown of the proxy server, waiting up to 5 seconds for network
traffic to stop.
|
void |
stopAutoAuthorization(String domain)
Deprecated.
Stops automatic authorization for the specified domain.
|
void |
waitForNetworkTrafficToStop(long quietPeriodInMs,
long timeoutInMs)
Deprecated.
|
boolean |
waitForQuiescence(long quietPeriod,
long timeout,
TimeUnit timeUnit)
Deprecated.
Waits for existing network traffic to stop, and for the specified quietPeriod to elapse.
|
void |
whitelistRequests(Collection<String> urlPatterns,
int statusCode)
Deprecated.
Whitelists URLs matching the specified regular expression patterns.
|
void |
whitelistRequests(String[] patterns,
int responseCode)
Deprecated.
Whitelists the specified requests.
|
public static final String ALLOW_NATIVE_DNS_FALLBACK
public ProxyServer()
public ProxyServer(int port)
public void start()
BrowserMobProxy
start
in interface BrowserMobProxy
start
in interface LegacyProxyServer
public void start(int port)
BrowserMobProxy
start
in interface BrowserMobProxy
port
- port to listen onpublic void start(int port, InetAddress bindAddress)
BrowserMobProxy
start
in interface BrowserMobProxy
port
- 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(int port, InetAddress clientBindAddress, InetAddress serverBindAddress)
BrowserMobProxy
start
in interface BrowserMobProxy
port
- 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()
BrowserMobProxy
isStarted
in interface BrowserMobProxy
public org.openqa.selenium.Proxy seleniumProxy() throws NameResolutionException
seleniumProxy
in interface LegacyProxyServer
NameResolutionException
public void cleanup()
cleanup
in interface LegacyProxyServer
public void stop()
BrowserMobProxy
stop
in interface BrowserMobProxy
stop
in interface LegacyProxyServer
public void abort()
BrowserMobProxy
BrowserMobProxy.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 BrowserMobProxy
abort
in interface LegacyProxyServer
public InetAddress getClientBindAddress()
BrowserMobProxy
getClientBindAddress
in interface BrowserMobProxy
public int getPort()
BrowserMobProxy
getPort
in interface BrowserMobProxy
getPort
in interface LegacyProxyServer
public InetAddress getServerBindAddress()
BrowserMobProxy
getServerBindAddress
in interface BrowserMobProxy
public void setPort(int port)
setPort
in interface LegacyProxyServer
public InetAddress getLocalHost()
setLocalHost(InetAddress)
, defaults to
0.0.0.0 (i.e. bind to any interface).
Note - just because we bound to the address, doesn't mean that it can be
reached. E.g. trying to connect to 0.0.0.0 is going to fail. Use
getConnectableLocalHost()
if you're looking for a host that can be
connected to.getLocalHost
in interface LegacyProxyServer
public InetAddress getConnectableLocalHost() throws UnknownHostException
InetAddress
that other processes can use to
contact the proxy.
In essence, this is the same as getLocalHost()
, but avoids
returning 0.0.0.0. as no-one can connect to that. If no other host has
been set via setLocalHost(InetAddress)
, will return
InetAddress.getLocalHost()
No attempt is made to check the address for reachability before it is
returned.getConnectableLocalHost
in interface LegacyProxyServer
UnknownHostException
public void setLocalHost(InetAddress localHost)
setLocalHost
in interface LegacyProxyServer
public Har getHar()
BrowserMobProxy
getHar
in interface BrowserMobProxy
getHar
in interface LegacyProxyServer
public Har newHar()
BrowserMobProxy
BrowserMobProxy.newPage()
. Enables HAR capture if it was not previously enabled.newHar
in interface BrowserMobProxy
public Har newHar(String initialPageRef)
BrowserMobProxy
newHar
in interface BrowserMobProxy
newHar
in interface LegacyProxyServer
initialPageRef
- initial page name of the new HAR filepublic Har newHar(String initialPageRef, String initialPageTitle)
BrowserMobProxy
newHar
in interface BrowserMobProxy
newHar
in interface LegacyProxyServer
initialPageRef
- initial page name of the new HAR fileinitialPageTitle
- initial page title of the new HAR filepublic void setHarCaptureTypes(Set<CaptureType> captureTypes)
BrowserMobProxy
CaptureType
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 BrowserMobProxy
captureTypes
- HAR data types to capturepublic void setHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxy
CaptureType
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 BrowserMobProxy
captureTypes
- HAR data types to capturepublic EnumSet<CaptureType> getHarCaptureTypes()
getHarCaptureTypes
in interface BrowserMobProxy
public void enableHarCaptureTypes(Set<CaptureType> captureTypes)
BrowserMobProxy
enableHarCaptureTypes
in interface BrowserMobProxy
captureTypes
- capture types to enablepublic void enableHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxy
enableHarCaptureTypes
in interface BrowserMobProxy
captureTypes
- capture types to enablepublic void disableHarCaptureTypes(Set<CaptureType> captureTypes)
BrowserMobProxy
disableHarCaptureTypes
in interface BrowserMobProxy
captureTypes
- capture types to disablepublic void disableHarCaptureTypes(CaptureType... captureTypes)
BrowserMobProxy
disableHarCaptureTypes
in interface BrowserMobProxy
captureTypes
- capture types to disablepublic Har newPage()
BrowserMobProxy
BrowserMobProxy.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 BrowserMobProxy
public Har newPage(String pageRef)
BrowserMobProxy
HarPageTimings.onLoad
value based on the amount of time the current page has been captured.newPage
in interface BrowserMobProxy
newPage
in interface LegacyProxyServer
pageRef
- name of the new pagepublic Har newPage(String pageRef, String pageTitle)
BrowserMobProxy
HarPageTimings.onLoad
value based on the amount of time the current page has been captured.newPage
in interface BrowserMobProxy
newPage
in interface LegacyProxyServer
pageRef
- name of the new pagepageTitle
- title of the new pagepublic Har endHar()
BrowserMobProxy
HarPageTimings.onLoad
value for the current page
based on the amount of time it has been captured.endHar
in interface BrowserMobProxy
public void setReadBandwidthLimit(long bytesPerSecond)
BrowserMobProxy
setReadBandwidthLimit
in interface BrowserMobProxy
bytesPerSecond
- maximum bandwidth, in bytes per secondpublic void setWriteBandwidthLimit(long bytesPerSecond)
BrowserMobProxy
setWriteBandwidthLimit
in interface BrowserMobProxy
bytesPerSecond
- maximum bandwidth, in bytes per secondpublic void setLatency(long latency, TimeUnit timeUnit)
BrowserMobProxy
setLatency
in interface BrowserMobProxy
latency
- minimum latency, or 0 for no minimumtimeUnit
- TimeUnit for the latencypublic void setConnectTimeout(int connectionTimeout, TimeUnit timeUnit)
BrowserMobProxy
setConnectTimeout
in interface BrowserMobProxy
connectionTimeout
- 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)
BrowserMobProxy
setIdleConnectionTimeout
in interface BrowserMobProxy
idleConnectionTimeout
- 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)
BrowserMobProxy
setRequestTimeout
in interface BrowserMobProxy
requestTimeout
- maximum time to wait for an HTTP response, or 0 to wait indefinitelytimeUnit
- TimeUnit for the requestTimeoutpublic void autoAuthorization(String domain, String username, String password, AuthType authType)
BrowserMobProxy
autoAuthorization
in interface BrowserMobProxy
domain
- domain automatically send authorization information tousername
- authorization usernamepassword
- authorization passwordauthType
- authorization typepublic void stopAutoAuthorization(String domain)
BrowserMobProxy
stopAutoAuthorization
in interface BrowserMobProxy
domain
- domain to stop automatically sending authorization information topublic void endPage()
endPage
in interface LegacyProxyServer
public void setRetryCount(int count)
setRetryCount
in interface LegacyProxyServer
public void addHeaders(Map<String,String> headers)
BrowserMobProxy
addHeaders
in interface BrowserMobProxy
headers
- Map<header name, header value>
to append to every request.public void remapHost(String source, String target)
remapHost
in interface LegacyProxyServer
@Deprecated public void addRequestInterceptor(org.apache.http.HttpRequestInterceptor i)
addRequestInterceptor
in interface LegacyProxyServer
public void addRequestInterceptor(RequestInterceptor interceptor)
addRequestInterceptor
in interface LegacyProxyServer
@Deprecated public void addResponseInterceptor(org.apache.http.HttpResponseInterceptor i)
addResponseInterceptor
in interface LegacyProxyServer
public void addResponseInterceptor(ResponseInterceptor interceptor)
addResponseInterceptor
in interface LegacyProxyServer
public StreamManager getStreamManager()
getStreamManager
in interface LegacyProxyServer
@Deprecated public void setDownstreamKbps(long downstreamKbps)
setDownstreamKbps
in interface LegacyProxyServer
@Deprecated public void setUpstreamKbps(long upstreamKbps)
setUpstreamKbps
in interface LegacyProxyServer
@Deprecated public void setLatency(long latency)
setLatency
in interface LegacyProxyServer
public void setRequestTimeout(int requestTimeout)
setRequestTimeout
in interface LegacyProxyServer
public void setSocketOperationTimeout(int readTimeout)
setSocketOperationTimeout
in interface LegacyProxyServer
public void setConnectionTimeout(int connectionTimeout)
setConnectionTimeout
in interface LegacyProxyServer
public void autoBasicAuthorization(String domain, String username, String password)
autoBasicAuthorization
in interface LegacyProxyServer
public void rewriteUrl(String match, String replace)
BrowserMobProxy
Pattern
).
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=anotherValue
rewriteUrl
in interface BrowserMobProxy
rewriteUrl
in interface LegacyProxyServer
match
- 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)
BrowserMobProxy
BrowserMobProxy.rewriteUrl(String, String)
for details on the format of the rewrite rules.rewriteUrls
in interface BrowserMobProxy
rewriteRules
- Map<urlPattern, replacementExpression>
public Map<String,String> getRewriteRules()
BrowserMobProxy
getRewriteRules
in interface BrowserMobProxy
Map<URL-matching regex, replacement expression>
public void removeRewriteRule(String urlPattern)
BrowserMobProxy
removeRewriteRule
in interface BrowserMobProxy
urlPattern
- rewrite rule pattern to removepublic void clearRewriteRules()
BrowserMobProxy
clearRewriteRules
in interface BrowserMobProxy
clearRewriteRules
in interface LegacyProxyServer
public void blacklistRequests(String pattern, int responseCode)
BrowserMobProxy
blacklistRequests
in interface BrowserMobProxy
blacklistRequests
in interface LegacyProxyServer
pattern
- URL-matching regular expression to blacklistresponseCode
- HTTP status code to returnpublic void blacklistRequests(String pattern, int responseCode, String method)
BrowserMobProxy
BrowserMobProxy.blacklistRequests(String, int)
for details on the URL the urlPattern will match.blacklistRequests
in interface BrowserMobProxy
blacklistRequests
in interface LegacyProxyServer
pattern
- URL-matching regular expression to blacklistresponseCode
- HTTP status code to returnmethod
- regular expression matching a request's HTTP methodpublic void setBlacklist(Collection<BlacklistEntry> blacklist)
BrowserMobProxy
setBlacklist
in interface BrowserMobProxy
blacklist
- new blacklist entriespublic Collection<BlacklistEntry> getBlacklist()
BrowserMobProxy
getBlacklist
in interface BrowserMobProxy
@Deprecated public List<BlacklistEntry> getBlacklistedRequests()
getBlacklistedRequests
in interface LegacyProxyServer
public Collection<BlacklistEntry> getBlacklistedUrls()
getBlacklistedUrls
in interface LegacyProxyServer
public boolean isWhitelistEnabled()
BrowserMobProxy
isWhitelistEnabled
in interface BrowserMobProxy
isWhitelistEnabled
in interface LegacyProxyServer
@Deprecated public List<Pattern> getWhitelistRequests()
getWhitelistRequests
in interface LegacyProxyServer
public Collection<String> getWhitelistUrls()
BrowserMobProxy
getWhitelistUrls
in interface BrowserMobProxy
getWhitelistUrls
in interface LegacyProxyServer
public int getWhitelistStatusCode()
BrowserMobProxy
getWhitelistStatusCode
in interface BrowserMobProxy
public int getWhitelistResponseCode()
getWhitelistResponseCode
in interface LegacyProxyServer
public void clearBlacklist()
BrowserMobProxy
clearBlacklist
in interface BrowserMobProxy
clearBlacklist
in interface LegacyProxyServer
public void whitelistRequests(Collection<String> urlPatterns, int statusCode)
BrowserMobProxy
whitelistRequests
in interface BrowserMobProxy
urlPatterns
- 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)
BrowserMobProxy
addWhitelistPattern
in interface BrowserMobProxy
urlPattern
- URL-matching regular expressions to whitelistpublic void whitelistRequests(String[] patterns, int responseCode)
Note: This method overwrites any existing whitelist.
whitelistRequests
in interface LegacyProxyServer
patterns
- regular expression patterns matching URLs to whitelistresponseCode
- response code to return for non-whitelisted URLspublic void enableEmptyWhitelist(int responseCode)
enableEmptyWhitelist
in interface BrowserMobProxy
enableEmptyWhitelist
in interface LegacyProxyServer
responseCode
- HTTP response code to return for all requestspublic void disableWhitelist()
BrowserMobProxy
disableWhitelist
in interface BrowserMobProxy
public void clearWhitelist()
clearWhitelist
in interface LegacyProxyServer
public void addHeader(String name, String value)
BrowserMobProxy
addHeader
in interface BrowserMobProxy
addHeader
in interface LegacyProxyServer
name
- name of the header to addvalue
- new header's valuepublic void removeHeader(String name)
BrowserMobProxy
BrowserMobProxy.addHeader(String name, String value)
.removeHeader
in interface BrowserMobProxy
name
- previously-added header's namepublic void removeAllHeaders()
BrowserMobProxy
BrowserMobProxy.addHeader(String name, String value)
.removeAllHeaders
in interface BrowserMobProxy
public Map<String,String> getAllHeaders()
BrowserMobProxy
BrowserMobProxy.addHeader(String name, String value)
.getAllHeaders
in interface BrowserMobProxy
Map<header name, header value>
public void setHostNameResolver(AdvancedHostResolver resolver)
BrowserMobProxy
ChainedHostResolver
.setHostNameResolver
in interface BrowserMobProxy
resolver
- host name resolverpublic AdvancedHostResolver getHostNameResolver()
BrowserMobProxy
getHostNameResolver
in interface BrowserMobProxy
public boolean waitForQuiescence(long quietPeriod, long timeout, TimeUnit timeUnit)
BrowserMobProxy
waitForQuiescence
in interface BrowserMobProxy
quietPeriod
- 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)
BrowserMobProxy
setChainedProxy
in interface BrowserMobProxy
chainedProxyAddress
- address and port of the upstream proxy, or null to remove an upstream proxypublic InetSocketAddress getChainedProxy()
BrowserMobProxy
getChainedProxy
in interface BrowserMobProxy
public void setCaptureHeaders(boolean captureHeaders)
setCaptureHeaders
in interface LegacyProxyServer
public void setCaptureContent(boolean captureContent)
setCaptureContent
in interface LegacyProxyServer
public void setCaptureBinaryContent(boolean captureBinaryContent)
setCaptureBinaryContent
in interface LegacyProxyServer
public void clearDNSCache()
clearDNSCache
in interface LegacyProxyServer
public void setDNSCacheTimeout(int timeout)
setDNSCacheTimeout
in interface LegacyProxyServer
public void waitForNetworkTrafficToStop(long quietPeriodInMs, long timeoutInMs)
waitForNetworkTrafficToStop
in interface LegacyProxyServer
public void setOptions(Map<String,String> options)
setOptions
in interface LegacyProxyServer
public void addFirstHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
BrowserMobProxy
HttpFiltersSource.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.
Note: This method is only available in the LittleProxy-based implementation of BrowserMob Proxy. The legacy ProxyServer
implementation will not use the HTTP filters. You must use the addRequestInterceptor() and addResponseInterceptor() methods in
LegacyProxyServer
when using the legacy ProxyServer implementation.addFirstHttpFilterFactory
in interface BrowserMobProxy
filterFactory
- factory to generate HttpFilterspublic void addLastHttpFilterFactory(org.littleshoot.proxy.HttpFiltersSource filterFactory)
BrowserMobProxy
HttpFiltersSource.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.
Note: This method is only available in the LittleProxy-based implementation of BrowserMob Proxy. The legacy ProxyServer
implementation will not use the HTTP filters. You must use the addRequestInterceptor() and addResponseInterceptor() methods in
LegacyProxyServer
when using the legacy ProxyServer implementation.addLastHttpFilterFactory
in interface BrowserMobProxy
filterFactory
- factory to generate HttpFilterspublic void addResponseFilter(ResponseFilter filter)
BrowserMobProxy
addResponseFilter
in interface BrowserMobProxy
filter
- filter instancepublic void addRequestFilter(RequestFilter filter)
BrowserMobProxy
addRequestFilter
in interface BrowserMobProxy
filter
- filter instancepublic void setMitmDisabled(boolean mitmDisabled)
BrowserMobProxy
setMitmDisabled
in interface BrowserMobProxy
mitmDisabled
- when true, MITM capture will be disabledpublic void setMitmManager(org.littleshoot.proxy.MitmManager mitmManager)
BrowserMobProxy
ImpersonatingMitmManager
and ImpersonatingMitmManager.Builder
for details on customizing the root and server certificate generation.setMitmManager
in interface BrowserMobProxy
mitmManager
- MITM manager to usepublic void setTrustAllServers(boolean trustAllServers)
BrowserMobProxy
setTrustAllServers
in interface BrowserMobProxy
trustAllServers
- when true, disables upstream server certificate verificationpublic void setTrustSource(TrustSource trustSource)
BrowserMobProxy
TrustSource
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 BrowserMobProxy
trustSource
- TrustSource containing root CAs, or null to disable upstream server validationpublic void cleanSslCertificates()
Copyright © 2016. All Rights Reserved.