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


Java DefaultHttpProxyServer类代码示例

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


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

示例1: setupDebugChannel

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
public DefaultHttpProxyServer setupDebugChannel(int port) {
	try {
		LOGGER.info("Proxy Debug Server start up, listening on port: " + port);
		DebugHttpFilterSource debugFilterSource = new DebugHttpFilterSource();
		DefaultHttpProxyServer debugServer = (DefaultHttpProxyServer) DefaultHttpProxyServer.bootstrap().withPort(port)
				.withManInTheMiddle(new ProxyServerMitmManager())
				.withFiltersSource(debugFilterSource).start();
		debugServer.setIdleConnectionTimeout(0);

		Bootstrap clientBootstrap = new Bootstrap();
		clientBootstrap.group(group)
				.channel(NioSocketChannel.class)
				.handler(new DebugNettyClientInitializer());
		debugChannel = clientBootstrap.connect("127.0.0.1", port).sync().channel();
		debugSslChannel = clientBootstrap.connect("127.0.0.1", port).sync().channel();
		return debugServer;
	} catch (Exception ex) {
		LOGGER.error(ex.getMessage());
	}
	return null;
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:22,代码来源:DebugManager.java

示例2: testSetupDebugChannel

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Test
public void testSetupDebugChannel() {
	DefaultHttpProxyServer debugServer = null;
	try {
		debugServer = debugManager.setupDebugChannel(7099);
		Assert.assertNotNull(debugServer);
		Assert.assertNotNull(readField(debugManager, "debugChannel"));
		Assert.assertNotNull(readField(debugManager, "debugSslChannel"));
	} catch (Exception ex) {
		Assert.fail(ex.getMessage());
	} finally {
		debugManager.shutdown();
		if (debugServer != null) {
			debugServer.stop();
		}
	}
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:18,代码来源:DebugManagerTest.java

示例3: main

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
public static void main(final String... args) {
    File log4jConfigurationFile = new File(
            "src/test/resources/log4j.xml");
    if (log4jConfigurationFile.exists()) {
        DOMConfigurator.configureAndWatch(
                log4jConfigurationFile.getAbsolutePath(), 15);
    }
    try {
        final int port = 9090;

        System.out.println("About to start server on port: " + port);
        HttpProxyServerBootstrap bootstrap = DefaultHttpProxyServer
                .bootstrapFromFile("./littleproxy.properties")
                .withPort(port).withAllowLocalOnly(false);

        bootstrap.withManInTheMiddle(new CertificateSniffingMitmManager());

        System.out.println("About to start...");
        bootstrap.start();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        System.exit(1);
    }
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:26,代码来源:Launcher.java

示例4: startProxyServerWithFilterAnsweringStatusCode

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
private void startProxyServerWithFilterAnsweringStatusCode(int statusCode) {
    final HttpResponseStatus status = HttpResponseStatus.valueOf(statusCode);
    HttpFiltersSource filtersSource = new HttpFiltersSourceAdapter() {
        @Override
        public HttpFilters filterRequest(HttpRequest originalRequest) {
            return new HttpFiltersAdapter(originalRequest) {
                @Override
                public HttpResponse clientToProxyRequest(HttpObject httpObject) {
                    return new DefaultHttpResponse(HttpVersion.HTTP_1_1, status);
                }
            };
        }
    };

    proxyServer = DefaultHttpProxyServer.bootstrap()
            .withPort(0)
            .withFiltersSource(filtersSource)
            .start();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:20,代码来源:DirectRequestTest.java

示例5: testClientIdleBeforeRequestReceived

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
/**
 * Verifies that when the client times out sending the initial request, the proxy still returns a Gateway Timeout.
 */
@Test
public void testClientIdleBeforeRequestReceived() throws IOException, InterruptedException {
    this.proxyServer = DefaultHttpProxyServer.bootstrap()
            .withPort(0)
            .withIdleConnectionTimeout(1)
            .start();

    // connect to the proxy and begin to transmit the request, but don't send the trailing \r\n that indicates the client has completely transmitted the request
    String successfulGet = "GET http://localhost:" + mockServerPort + "/success HTTP/1.1";

    // using the SocketClientUtil since we want the client to fail to send the entire GET request, which is not possible with
    // Apache HTTP client and most other HTTP clients
    Socket socket = SocketClientUtil.getSocketToProxyServer(proxyServer);

    SocketClientUtil.writeStringToSocket(successfulGet, socket);

    // wait a bit to allow the proxy server to respond
    Thread.sleep(1500);

    // the proxy should return an HTTP 504 due to the timeout
    String response = SocketClientUtil.readStringFromSocket(socket);
    assertThat("Expected to receive an HTTP 504 Gateway Timeout from the server", response, startsWith("HTTP/1.1 504"));

    socket.close();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:29,代码来源:TimeoutTest.java

示例6: aWarmUpTest

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Test
public void aWarmUpTest() throws IOException {
    // a "warm-up" test so the first test's results are not skewed due to classloading, etc. guaranteed to run
    // first with the @FixMethodOrder(MethodSorters.NAME_ASCENDING) annotation on the class.

    HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
            .withPort(0)
            .withThrottling(0, THROTTLED_WRITE_BYTES_PER_SECOND)
            .start();

    int proxyPort = proxyServer.getListenAddress().getPort();

    HttpGet request = createHttpGet();
    DefaultHttpClient httpClient = createHttpClient(proxyPort);

    EntityUtils.consumeQuietly(httpClient.execute(new HttpHost("127.0.0.1", writeWebServerPort), request).getEntity());

    EntityUtils.consumeQuietly(httpClient.execute(new HttpHost("127.0.0.1", readWebServerPort), request).getEntity());
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:20,代码来源:ThrottlingTest.java

示例7: setup

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    assumeTrue("Skipping due to non-Unix OS", TestUtils.isUnixManagementCapable());

    assumeFalse("Skipping for travis-ci build", "true".equals(System.getenv("TRAVIS")));

    webServer = new Server(0);
    webServer.start();
    webServerPort = TestUtils.findLocalHttpPort(webServer);

    proxyServer = DefaultHttpProxyServer.bootstrap()
            .withPort(0)
            .start();
    proxyServer.setIdleConnectionTimeout(10);

}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:17,代码来源:IdleTest.java

示例8: aWarmUpTest

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Test
public void aWarmUpTest() throws IOException {
    // a "warm-up" test so the first test's results are not skewed due to classloading, etc. guaranteed to run
    // first with the @FixMethodOrder(MethodSorters.NAME_ASCENDING) annotation on the class.

    HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
            .withPort(0)
            .withThrottling(0, THROTTLED_WRITE_BYTES_PER_SECOND)
            .start();

    int proxyPort = proxyServer.getListenAddress().getPort();

    HttpGet request = createHttpGet();
    DefaultHttpClient httpClient = createHttpClient(proxyPort);

    EntityUtils.consumeQuietly(httpClient.execute(new HttpHost("127.0.0.1", WRITE_WEB_SERVER_PORT), request).getEntity());

    EntityUtils.consumeQuietly(httpClient.execute(new HttpHost("127.0.0.1", READ_WEB_SERVER_PORT), request).getEntity());
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:20,代码来源:ThrottlingTest.java

示例9: setUp

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    adapter.reset();
    proxyServer = DefaultHttpProxyServer
        .bootstrap()
        .withAddress(ALL_INTERFACES_AUTOMATIC_PORT)
        .withFiltersSource(adapter)
        .start();
    final InetSocketAddress proxyAddress = proxyServer.getListenAddress();
    proxyPort = Integer.toString(proxyAddress.getPort(), 10);

    oldProperties = System.getProperties();
    final Properties tempProperties = new Properties(oldProperties);
    System.setProperties(tempProperties);
    final InetAddress localHostAddress = InetAddress.getLocalHost();
    localHostName = localHostAddress.getHostName();
    wireMockPort = wireMockRule.port();
}
 
开发者ID:Microsoft,项目名称:oauth2-useragent,代码行数:19,代码来源:AppTest.java

示例10: start

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
public void start() throws IOException {
    HttpProxyServerBootstrap boot = null;
    if ("client".equals(mode)) {
        boot = DefaultHttpProxyServer.bootstrap()
                .withAddress(new InetSocketAddress("localhost", port))
                .withChainProxyManager(chainedProxyManager())
                .withTransportProtocol(TransportProtocol.TCP);
        if (cache) {
            boot = boot.withFiltersSource(filter);
        }

    } else if ("server".equals(mode)) {
        SslEngineSource sslEngineSource = new KazeSslEngineSource(
                "kserver.jks", "tserver.jks", false, true, "serverkey",
                jkspw);
        boot = DefaultHttpProxyServer.bootstrap()
                .withAddress(new InetSocketAddress("0.0.0.0", port))
                .withTransportProtocol(TransportProtocol.TCP)
                .withSslEngineSource(sslEngineSource)
                .withAuthenticateSslClients(false);
    }
    boot.start();
    System.in.read();
}
 
开发者ID:chocotan,项目名称:kazeproxy,代码行数:25,代码来源:KazeProxy.java

示例11: setupProxy

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@BeforeClass
public static void setupProxy() {
    ProxyAuthenticator auth = new ProxyAuthenticator() {

        @Override
        public boolean authenticate(String username, String password) {
            return proxyUsername.equals(username) && proxyPassword.equals(password);
        }

        @Override
        public String getRealm() {
            return null;
        }

    };
    server = DefaultHttpProxyServer.bootstrap().withPort(proxyPort).withProxyAuthenticator(auth).start();

    setProxySettingForClient();
}
 
开发者ID:Talend,项目名称:components,代码行数:20,代码来源:SalesforceProxyTestIT.java

示例12: run

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Override
public void run(String... args) throws Exception {
    server = DefaultHttpProxyServer.bootstrap()
            .withPort(conf.getPort())
            .withAllowLocalOnly(false)
            .withFiltersSource(new ProxyServerFilterSource())
            .withManInTheMiddle(new CertificateSniffingMitmManager())
            .start();
}
 
开发者ID:storezhang,项目名称:proxy-server,代码行数:10,代码来源:ProxyServerTask.java

示例13: start

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的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

示例14: main

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
public static void main(String[] args) throws RootCertificateException {
    LOGGER.info("Server Start");
    HttpProxyServer server =
            DefaultHttpProxyServer.bootstrap()
                    .withAddress(new InetSocketAddress("0.0.0.0", 8888))
                    .withManInTheMiddle(new CertificateSniffingMitmManager())
                    .withFiltersSource(new ResourceFilter())
                    .start();
}
 
开发者ID:zh-h,项目名称:pxclawer,代码行数:10,代码来源:ProxyServer.java

示例15: start

import org.littleshoot.proxy.impl.DefaultHttpProxyServer; //导入依赖的package包/类
@Override
public void start() {
	if (proxy == null) {
		proxy = DefaultHttpProxyServer.bootstrap()
				.withPort(port)
				.withFiltersSource(getFiltersSource())
				.start();
	}
}
 
开发者ID:abuchanan920,项目名称:historybook,代码行数:10,代码来源:LittleProxy.java


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