use of org.asynchttpclient.test.EchoHandler in project async-http-client by AsyncHttpClient.
the class BasicHttpProxyToHttpsTest method setUpGlobal.
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
// HTTP server
httpServer = new Server();
ServerConnector connector1 = addHttpsConnector(httpServer);
httpServer.setHandler(new EchoHandler());
httpServer.start();
httpPort = connector1.getLocalPort();
// proxy
proxy = new Server();
ServerConnector connector2 = addHttpConnector(proxy);
ConnectHandler connectHandler = new ConnectHandler() {
@Override
protected boolean handleAuthentication(HttpServletRequest request, HttpServletResponse response, String address) {
String authorization = request.getHeader(PROXY_AUTHORIZATION.toString());
if (authorization == null) {
response.setStatus(HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED);
response.setHeader(PROXY_AUTHENTICATE.toString(), "Basic realm=\"Fake Realm\"");
return false;
} else if (authorization.equals("Basic am9obmRvZTpwYXNz")) {
return true;
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return false;
}
};
proxy.setHandler(connectHandler);
proxy.start();
proxyPort = connector2.getLocalPort();
LOGGER.info("Local HTTP Server (" + httpPort + "), Proxy (" + proxyPort + ") started successfully");
}
use of org.asynchttpclient.test.EchoHandler in project async-http-client by AsyncHttpClient.
the class AbstractAsyncHttpClientFactoryTest method setUpBeforeTest.
@BeforeClass(alwaysRun = true)
public void setUpBeforeTest() throws Exception {
server = new Server();
ServerConnector connector = addHttpConnector(server);
server.setHandler(new EchoHandler());
server.start();
port = connector.getLocalPort();
}
use of org.asynchttpclient.test.EchoHandler in project async-http-client by AsyncHttpClient.
the class HttpsProxyTest method setUpGlobal.
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
server = new Server();
ServerConnector connector = addHttpConnector(server);
server.setHandler(configureHandler());
server.start();
port1 = connector.getLocalPort();
server2 = new Server();
ServerConnector connector2 = addHttpsConnector(server2);
server2.setHandler(new EchoHandler());
server2.start();
port2 = connector2.getLocalPort();
logger.info("Local HTTP server started successfully");
}
use of org.asynchttpclient.test.EchoHandler in project async-http-client by AsyncHttpClient.
the class HttpsProxyTest method setUpGlobal.
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
server = new Server();
ServerConnector connector1 = addHttpConnector(server);
server.setHandler(configureHandler());
server.start();
port1 = connector1.getLocalPort();
server2 = new Server();
ServerConnector connector2 = addHttpsConnector(server2);
server2.setHandler(new EchoHandler());
server2.start();
port2 = connector2.getLocalPort();
logger.info("Local HTTP server started successfully");
}
use of org.asynchttpclient.test.EchoHandler in project async-http-client by AsyncHttpClient.
the class BasicHttpProxyToHttpTest method setUpGlobal.
@BeforeClass
public void setUpGlobal() throws Exception {
httpServer = new Server();
ServerConnector connector1 = addHttpConnector(httpServer);
httpServer.setHandler(new EchoHandler());
httpServer.start();
httpPort = connector1.getLocalPort();
proxy = new Server();
ServerConnector connector2 = addHttpConnector(proxy);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(BasicAuthProxyServlet.class, "/*");
servletHolder.setInitParameter("maxThreads", "20");
proxy.setHandler(servletHandler);
proxy.start();
proxyPort = connector2.getLocalPort();
LOGGER.info("Local HTTP Server (" + httpPort + "), Proxy (" + proxyPort + ") started successfully");
}
Aggregations