net.lightbody.bmp.BrowserMobProxyServer Java Examples
The following examples show how to use
net.lightbody.bmp.BrowserMobProxyServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowserMobHttpFilterChain.java From CapturePacket with MIT License | 6 votes |
public BrowserMobHttpFilterChain(BrowserMobProxyServer proxyServer, HttpRequest originalRequest, ChannelHandlerContext ctx) { super(originalRequest, ctx); this.proxyServer = proxyServer; if (proxyServer.getFilterFactories() != null) { filters = new ArrayList<>(proxyServer.getFilterFactories().size()); // instantiate all HttpFilters using the proxy's filter factories for (HttpFiltersSource filterFactory : proxyServer.getFilterFactories()) { HttpFilters filter = filterFactory.filterRequest(originalRequest, ctx); // allow filter factories to avoid adding a filter on a per-request basis by returning a null // HttpFilters instance if (filter != null) { filters.add(filter); } } } else { filters = Collections.emptyList(); } }
Example #2
Source File: CaptureService.java From CapturePacket with MIT License | 6 votes |
@Override public void run() { try { mProxyServer = new BrowserMobProxyServer(mKeyStoreDir); mProxyServer.setTrustAllServers(true); mProxyServer.start(PROXY_PORT); mProxyServer.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_HEADERS, CaptureType.REQUEST_COOKIES, CaptureType.RESPONSE_CONTENT); String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) .format(new Date(System.currentTimeMillis())); mProxyServer.newHar(time); mProxyState = STATE_SUCCESS; }catch (Throwable e){ CrashReport.postCatchedException(e); mProxyState = STATE_FAIL; } if (mCaptureBinder != null) { mCaptureBinder.setProxyServer(mProxyServer); mCaptureBinder.setProxyState(mProxyState); } }
Example #3
Source File: ProxyBasedIT.java From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License | 6 votes |
@Test public void usingAProxyToTrackNetworkTrafficStep2() { BrowserMobProxy browserMobProxy = new BrowserMobProxyServer(); browserMobProxy.start(); Proxy seleniumProxyConfiguration = ClientUtil.createSeleniumProxy(browserMobProxy); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setCapability(CapabilityType.PROXY, seleniumProxyConfiguration); driver = new FirefoxDriver(firefoxOptions); browserMobProxy.newHar(); driver.get("https://www.google.co.uk"); Har httpArchive = browserMobProxy.getHar(); assertThat(getHTTPStatusCode("https://www.google.co.uk/", httpArchive)) .isEqualTo(200); }
Example #4
Source File: RequestFilterRegistryTest.java From bobcat with Apache License 2.0 | 6 votes |
@Disabled("TODO - some problems with timing (works in debug mode)") @Test public void shouldCallFilterByRegistry() throws IOException { // given BrowserMobProxy browserMobProxy = new BrowserMobProxyServer(); startProxyServer(browserMobProxy); requestFilterRegistry.add(requestFilter); browserMobProxy.addRequestFilter(requestFilterRegistry); // when DesiredCapabilities capabilities = proxyCapabilities(browserMobProxy); visitSamplePage(capabilities); browserMobProxy.stop(); // then verify(requestFilter, atLeastOnce()).filterRequest(any(HttpRequest.class), any(HttpMessageContents.class), any(HttpMessageInfo.class)); }
Example #5
Source File: BrowserMobHttpFilterChain.java From Dream-Catcher with MIT License | 6 votes |
public BrowserMobHttpFilterChain(BrowserMobProxyServer proxyServer, HttpRequest originalRequest, ChannelHandlerContext ctx) { super(originalRequest, ctx); this.proxyServer = proxyServer; if (proxyServer.getFilterFactories() != null) { filters = new ArrayList<>(proxyServer.getFilterFactories().size()); // instantiate all HttpFilters using the proxy's filter factories for (HttpFiltersSource filterFactory : proxyServer.getFilterFactories()) { HttpFilters filter = filterFactory.filterRequest(originalRequest, ctx); // allow filter factories to avoid adding a filter on a per-request basis by returning a null // HttpFilters instance if (filter != null) { filters.add(filter); } } } else { filters = Collections.emptyList(); } }
Example #6
Source File: BrowserMobHttpFilterChain.java From AndroidHttpCapture with MIT License | 6 votes |
public BrowserMobHttpFilterChain(BrowserMobProxyServer proxyServer, HttpRequest originalRequest, ChannelHandlerContext ctx) { super(originalRequest, ctx); this.proxyServer = proxyServer; if (proxyServer.getFilterFactories() != null) { filters = new ArrayList<>(proxyServer.getFilterFactories().size()); // instantiate all HttpFilters using the proxy's filter factories for (HttpFiltersSource filterFactory : proxyServer.getFilterFactories()) { HttpFilters filter = filterFactory.filterRequest(originalRequest, ctx); // allow filter factories to avoid adding a filter on a per-request basis by returning a null // HttpFilters instance if (filter != null) { filters.add(filter); } } } else { filters = Collections.emptyList(); } }
Example #7
Source File: ProxyBasedIT.java From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License | 5 votes |
@Test public void usingAProxyToTrackNetworkTrafficStep1() { BrowserMobProxy browserMobProxy = new BrowserMobProxyServer(); browserMobProxy.start(); Proxy seleniumProxyConfiguration = ClientUtil.createSeleniumProxy(browserMobProxy); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setCapability(CapabilityType.PROXY, seleniumProxyConfiguration); driver = new FirefoxDriver(firefoxOptions); browserMobProxy.newHar(); driver.get("https://www.google.co.uk"); }
Example #8
Source File: DefaultModule.java From bromium with MIT License | 5 votes |
public BrowserMobProxy createBrowserMobProxy(int timeout, RequestFilter requestFilter, ResponseFilter responseFilter) { BrowserMobProxyServer proxy = new BrowserMobProxyServer(); proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT); proxy.newHar("measurements"); proxy.addRequestFilter(requestFilter); proxy.addResponseFilter(responseFilter); proxy.setIdleConnectionTimeout(timeout, TimeUnit.SECONDS); proxy.setRequestTimeout(timeout, TimeUnit.SECONDS); return proxy; }
Example #9
Source File: ProxyController.java From bobcat with Apache License 2.0 | 5 votes |
ProxyController( Set<ProxyEventListener> eventListeners, RequestFilterRegistry filterRegistry, int port) { this.browserMobProxy = new BrowserMobProxyServer(); this.eventListeners = eventListeners; this.filterRegistry = filterRegistry; this.port = port; }
Example #10
Source File: ProxyPool.java From carina with Apache License 2.0 | 5 votes |
/** * create BrowserMobProxy Server object * @return BrowserMobProxy * */ public static BrowserMobProxy createProxy() { BrowserMobProxyServer proxy = new BrowserMobProxyServer(); proxy.setTrustAllServers(true); //System.setProperty("jsse.enableSNIExtension", "false"); // disable MITM in case we do not need it proxy.setMitmDisabled(Configuration.getBoolean(Parameter.BROWSERMOB_MITM)); return proxy; }
Example #11
Source File: HarLog.java From CapturePacket with MIT License | 4 votes |
public HarLog(HarNameVersion creator, BrowserMobProxyServer server) { this.creator = creator; this.server = server; }
Example #12
Source File: CaptureBinder.java From CapturePacket with MIT License | 4 votes |
public void setProxyServer(BrowserMobProxyServer proxyServer) { mProxyServer = proxyServer; }
Example #13
Source File: BrowsermobProxyUtilsImpl.java From IridiumApplicationTesting with MIT License | 4 votes |
/** * Starts the Browsermob Proxy * * @return The port that the proxy is listening on */ private ProxyDetails<BrowserMobProxy> startBrowsermobProxy( @NotNull final Optional<ProxySettings> upstreamProxy) throws Exception { final BrowserMobProxy browserMobProxy = new BrowserMobProxyServer(); browserMobProxy.setTrustAllServers(true); /* Prevent errors like this: 09:58:29.348 [LittleProxy-0-ProxyToServerWorker-2] ERROR o.l.p.impl.ProxyToServerConnection - (AWAITING_INITIAL) [id: 0x95af9921, L:/127.0.0.1:60359 - R:/127.0.0.1:3128]: Caught an exception on ProxyToServerConnection io.netty.handler.codec.TooLongFrameException: HTTP content length exceeded 2097152 bytes. */ browserMobProxy.addFirstHttpFilterFactory(new HttpFiltersSourceAdapter() { @Override public int getMaximumRequestBufferSizeInBytes() { return Integer.MAX_VALUE; } @Override public int getMaximumResponseBufferSizeInBytes() { return Integer.MAX_VALUE; } }); if (upstreamProxy.isPresent()) { browserMobProxy.setChainedProxy(new InetSocketAddress( upstreamProxy.get().getHost(), upstreamProxy.get().getPort())); if (StringUtils.isNotBlank(upstreamProxy.get().getUsername())) { browserMobProxy.chainedProxyAuthorization( upstreamProxy.get().getUsername(), upstreamProxy.get().getPassword(), AuthType.BASIC); } } browserMobProxy.start(0); final ProxyDetails<BrowserMobProxy> proxyDetails = new ProxyDetailsImpl<>(browserMobProxy.getPort(), true, PROXY_NAME, browserMobProxy); trackErrorResponses(browserMobProxy, proxyDetails); return proxyDetails; }
Example #14
Source File: HarLog.java From AndroidHttpCapture with MIT License | 4 votes |
public HarLog(HarNameVersion creator,BrowserMobProxyServer server) { this.creator = creator; this.server = server; }