Search in sources :

Example 1 with ThreadPoolConfiguration

use of org.littleshoot.proxy.impl.ThreadPoolConfiguration in project nifi by apache.

the class TestHttpClient method startProxyServerWithAuth.

private static void startProxyServerWithAuth() throws IOException {
    int proxyServerPort;
    try (final ServerSocket serverSocket = new ServerSocket(0)) {
        proxyServerPort = serverSocket.getLocalPort();
    }
    proxyServerWithAuth = DefaultHttpProxyServer.bootstrap().withPort(proxyServerPort).withAllowLocalOnly(true).withProxyAuthenticator(new ProxyAuthenticator() {

        @Override
        public boolean authenticate(String userName, String password) {
            return PROXY_USER.equals(userName) && PROXY_PASSWORD.equals(password);
        }

        @Override
        public String getRealm() {
            return "NiFi Unit Test";
        }
    }).withThreadPoolConfiguration(new ThreadPoolConfiguration().withAcceptorThreads(2).withClientToProxyWorkerThreads(4).withProxyToServerWorkerThreads(4)).start();
}
Also used : ProxyAuthenticator(org.littleshoot.proxy.ProxyAuthenticator) ThreadPoolConfiguration(org.littleshoot.proxy.impl.ThreadPoolConfiguration) ServerSocket(java.net.ServerSocket)

Example 2 with ThreadPoolConfiguration

use of org.littleshoot.proxy.impl.ThreadPoolConfiguration in project nifi by apache.

the class TestHttpClient method startProxyServer.

private static void startProxyServer() throws IOException {
    int proxyServerPort;
    try (final ServerSocket serverSocket = new ServerSocket(0)) {
        proxyServerPort = serverSocket.getLocalPort();
    }
    proxyServer = DefaultHttpProxyServer.bootstrap().withPort(proxyServerPort).withAllowLocalOnly(true).withThreadPoolConfiguration(new ThreadPoolConfiguration().withAcceptorThreads(2).withClientToProxyWorkerThreads(4).withProxyToServerWorkerThreads(4)).start();
}
Also used : ThreadPoolConfiguration(org.littleshoot.proxy.impl.ThreadPoolConfiguration) ServerSocket(java.net.ServerSocket)

Aggregations

ServerSocket (java.net.ServerSocket)2 ThreadPoolConfiguration (org.littleshoot.proxy.impl.ThreadPoolConfiguration)2 ProxyAuthenticator (org.littleshoot.proxy.ProxyAuthenticator)1