Examples of RequestInterceptor


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

Examples of org.browsermob.proxy.http.RequestInterceptor

    }

    @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

Examples of org.browsermob.proxy.http.RequestInterceptor

        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

Examples of org.browsermob.proxy.http.RequestInterceptor

        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

Examples of org.browsermob.proxy.http.RequestInterceptor

        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

Examples of org.mockserver.proxy.interceptor.RequestInterceptor

                // Create a default pipeline implementation.
                ChannelPipeline pipeline = ch.pipeline();

                // add handler
                InetSocketAddress remoteSocketAddress = new InetSocketAddress(directRemoteHost, directRemotePort);
                pipeline.addLast(new DirectProxyUpstreamHandler(remoteSocketAddress, false, 1048576, new RequestInterceptor(remoteSocketAddress), "                -->"));
            }
        }, directLocalPort, false);
    }
View Full Code Here

Examples of org.mockserver.proxy.interceptor.RequestInterceptor

                engine.setUseClientMode(false);
                pipeline.addLast("ssl inbound", new SslHandler(engine));

                // add handler
                InetSocketAddress remoteSocketAddress = new InetSocketAddress(directRemoteHost, directRemotePort);
                pipeline.addLast(new DirectProxyUpstreamHandler(remoteSocketAddress, true, 1048576, new RequestInterceptor(remoteSocketAddress), "                -->"));

            }
        }, directLocalSecurePort, false);
    }
View Full Code Here

Examples of org.mockserver.proxy.interceptor.RequestInterceptor

                                            }
                                            Logger outboundLogger = LoggerFactory.getLogger("                -->");
                                            if (logger.isDebugEnabled()) {
                                                outboundChannel.pipeline().addLast("outbound relay logger", new LoggingHandler(outboundLogger));
                                            }
                                            outboundChannel.pipeline().addLast(new ProxyRelayHandler(ctx.channel(), 1048576, new RequestInterceptor(null), outboundLogger));


                                            // upstream
                                            if (secure) {
                                                SSLEngine serverEngine = SSLFactory.getInstance().sslContext().createSSLEngine();
View Full Code Here

Examples of retrofit.RequestInterceptor

     * access token following the standardized OAuth 2.0 Bearer Token Specification as per the Content Delivery API.
     *
     * This also sets the {@code "User-Agent"} header on the request.
     */
    private RequestInterceptor getRequestInterceptor() {
        return new RequestInterceptor() {
            @Override
            public void intercept(RequestFacade requestFacade) {
                if (accessToken != null && !accessToken.isEmpty()) {
                    requestFacade.addHeader(HTTP_HEADER_AUTH,
                            String.format(HTTP_OAUTH_PATTERN, accessToken));
View Full Code Here

Examples of retrofit.RequestInterceptor

     * access token following the standardized OAuth 2.0 Bearer Token Specification as per the Content Delivery API.
     *
     * This also sets the {@code "User-Agent"} header on the request.
     */
    private RequestInterceptor getRequestInterceptor() {
        return new RequestInterceptor() {
            @Override
            public void intercept(RequestFacade requestFacade) {
                if (accessToken != null && !accessToken.isEmpty()) {
                    requestFacade.addHeader(HTTP_HEADER_AUTH,
                            String.format(HTTP_OAUTH_PATTERN, accessToken));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.