当前位置: 首页>>代码示例>>Java>>正文


Java HttpFiltersSourceAdapter类代码示例

本文整理汇总了Java中org.littleshoot.proxy.HttpFiltersSourceAdapter的典型用法代码示例。如果您正苦于以下问题:Java HttpFiltersSourceAdapter类的具体用法?Java HttpFiltersSourceAdapter怎么用?Java HttpFiltersSourceAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpFiltersSourceAdapter类属于org.littleshoot.proxy包,在下文中一共展示了HttpFiltersSourceAdapter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHttpFiltersSourceAdapter

import org.littleshoot.proxy.HttpFiltersSourceAdapter; //导入依赖的package包/类
private HttpFiltersSourceAdapter createHttpFiltersSourceAdapter() {
    return new HttpFiltersSourceAdapter() {
        @Override
        public HttpFilters filterRequest(HttpRequest originalRequest) {
            if (toRecord) {
                return new ProxyEaterFilter(storage, originalRequest);
            } else {
                return new ProxyRegurgitatorFilter(storage, originalRequest);
            }
        }

        //*
        // Notice that the limit might give some trouble. Consider increasing significantly,
        // _or_ handle chunks
        @Override
        public int getMaximumRequestBufferSizeInBytes() {
            return 10 * 1024 * 1024;
        }

        @Override
        public int getMaximumResponseBufferSizeInBytes() {
            return 10 * 1024 * 1024;
        }
        //*/
    };
}
 
开发者ID:amedia,项目名称:regurgitator,代码行数:27,代码来源:IndexResource.java

示例2: start

import org.littleshoot.proxy.HttpFiltersSourceAdapter; //导入依赖的package包/类
public HttpProxyServer start() {

        return DefaultHttpProxyServer.bootstrap()
            .withAddress(new InetSocketAddress(host, port))
            .withFiltersSource(new HttpFiltersSourceAdapter() {

                @Override
                public HttpFilters filterRequest(HttpRequest originalRequest) {

                    return new HttpFiltersAdapter(originalRequest) {

                        final String mockedAddress = mockServer + ":" + mockPort;

                        @Override
                        public HttpResponse clientToProxyRequest(HttpObject httpObject) {

                            final HttpRequest request = (HttpRequest) httpObject;

                            if (request.getUri().contains("google")) {
                                request.setUri(mockedAddress);
                            }

                            super.clientToProxyRequest(request);

                            return null;
                        }
                    };
                }
            }).start();
    }
 
开发者ID:aerogear,项目名称:push-network-proxies,代码行数:31,代码来源:MockingFCMProxyServer.java

示例3: start

import org.littleshoot.proxy.HttpFiltersSourceAdapter; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void start() {
    List<Handler<HttpObject>> httpHandlerList = (List<Handler<HttpObject>>) getHandlerList();
    DefaultHttpProxyServer.bootstrap()
            .withPort(port).withFiltersSource(new HttpFiltersSourceAdapter() {
        @Override
        public HttpFilters filterRequest(HttpRequest originalRequest) {
            return new HttpFiltersAdapter(originalRequest) {
                @Override
                public HttpResponse clientToProxyRequest(HttpObject httpObject) {
                    httpHandlerList.forEach(httpObjectHandler -> httpObjectHandler.client2Proxy(httpObject));
                    return null;
                }
            };
        }
    }).start();
}
 
开发者ID:smxydx,项目名称:vector,代码行数:19,代码来源:DefaultProxyBase.java

示例4: startProxy

import org.littleshoot.proxy.HttpFiltersSourceAdapter; //导入依赖的package包/类
/**
 * Runs a proxy server counting requests
 * @param authenticating true if the proxy should require authentication
 * @throws Exception if an error occurred
 */
private void startProxy(boolean authenticating) throws Exception {
    proxyPort = findPort();
    
    HttpProxyServerBootstrap bootstrap = DefaultHttpProxyServer.bootstrap()
            .withPort(proxyPort)
            .withFiltersSource(new HttpFiltersSourceAdapter() {
                public HttpFilters filterRequest(HttpRequest originalRequest,
                        ChannelHandlerContext ctx) {
                   return new HttpFiltersAdapter(originalRequest) {
                      @Override
                      public void proxyToServerRequestSent() {
                          proxyCounter++;
                      }
                   };
                }
            });
    
    if (authenticating) {
        bootstrap = bootstrap.withProxyAuthenticator(new ProxyAuthenticator() {
            @Override
            public boolean authenticate(String userName, String password) {
                return PROXY_USERNAME.equals(userName) &&
                        PROXY_PASSWORD.equals(password);
            }

            @Override
            public String getRealm() {
                return "gradle-download-task";
            }
        });
    }
    
    proxy = bootstrap.start();
}
 
开发者ID:michel-kraemer,项目名称:gradle-download-task,代码行数:40,代码来源:ProxyTest.java


注:本文中的org.littleshoot.proxy.HttpFiltersSourceAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。