Package org.littleshoot.proxy

Examples of org.littleshoot.proxy.HttpFiltersSourceAdapter


            public OperationalContext retrieve() {
                return urlToContextMapping.get(proxyUrl);
            }
        };

        final HttpFiltersSourceAdapter httpFiltersSource = serviceLoader().onlyOne(HttpFiltersSourceAdapter.class);

        final ContextualOperation<HttpRequest, HttpFilters> filterRequest = Contextualizer.contextualize(retriever,
            new ContextualOperation<HttpRequest, HttpFilters>() {
                @Override
                public HttpFilters performInContext(HttpRequest originalRequest) {
                    return httpFiltersSource.filterRequest(originalRequest);
                }
            }
        );

        final InetSocketAddress bindToAddress = new InetSocketAddress(proxyUrl.getHost(), proxyUrl.getPort());
        final InetSocketAddress forwardToAddress = new InetSocketAddress(realUrl.getHost(), realUrl.getPort());

        return DefaultHttpProxyServer
            .bootstrap()
            .withAddress(bindToAddress)
            .withTransparent(true)
            .withChainProxyManager(new ChainedProxyManager() {

                @Override
                public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
                    chainedProxies.add(new ChainedProxyAdapter() {
                        @Override
                        public InetSocketAddress getChainedProxyAddress() {
                            return forwardToAddress;
                        }
                    });
                }
            })
            .withFiltersSource(new HttpFiltersSourceAdapter() {

                @Override
                public HttpFilters filterRequest(HttpRequest originalRequest) {
                    return filterRequest.performInContext(originalRequest);
                }



                @Override
                public int getMaximumRequestBufferSizeInBytes() {
                    return httpFiltersSource.getMaximumRequestBufferSizeInBytes();
                }

                @Override
                public int getMaximumResponseBufferSizeInBytes() {
                    return httpFiltersSource.getMaximumResponseBufferSizeInBytes();
                }
            })
            .start();
    }
View Full Code Here

TOP

Related Classes of org.littleshoot.proxy.HttpFiltersSourceAdapter

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.