Package org.browsermob.proxy.http

Examples of org.browsermob.proxy.http.RequestInterceptor


public class MailingListIssuesTest extends DummyServerTest {
    @Test
    public void testThatInterceptorIsCalled() throws IOException, InterruptedException {
        final boolean[] interceptorHit = {false};
        proxy.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public void process(BrowserMobHttpRequest request) {
                interceptorHit[0] = true;
            }
        });
View Full Code Here


    }

    @Test
    public void testThatInterceptorCanCaptureCallingIpAddress() throws IOException, InterruptedException {
        final String[] remoteHost = {null};
        proxy.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public void process(BrowserMobHttpRequest request) {
                remoteHost[0] = request.getProxyRequest().getRemoteHost();
            }
        });
View Full Code Here

        Assert.assertEquals("Remote host incorrect", "127.0.0.1", remoteHost[0]);
    }

    @Test
    public void testThatWeCanChangeTheUserAgent() throws IOException, InterruptedException {
        proxy.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public void process(BrowserMobHttpRequest request) {
                request.getMethod().removeHeaders("User-Agent");
                request.getMethod().addHeader("User-Agent", "Bananabot/1.0");
            }
View Full Code Here

        Assert.assertTrue(body.contains("this is a.txt"));
    }

    @Test
    public void testThatInterceptorsCanRewriteUrls() throws IOException, InterruptedException {
        proxy.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public void process(BrowserMobHttpRequest request) {
                try {
                    request.getMethod().setURI(new URI("http://127.0.0.1:8080/b.txt"));
                } catch (URISyntaxException e) {
View Full Code Here

        ScriptEngineManager mgr = new ScriptEngineManager();
        final ScriptEngine engine = mgr.getEngineByName("JavaScript");
        Compilable compilable = (Compilableengine;
        final CompiledScript script = compilable.compile(baos.toString());

        proxy.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public void process(BrowserMobHttpRequest request) {
                Bindings bindings = engine.createBindings();
                bindings.put("request", request);
                bindings.put("log", LOG);
View Full Code Here

TOP

Related Classes of org.browsermob.proxy.http.RequestInterceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.