use of org.littleshoot.proxy.HttpFilters in project td-client-java by treasure-data.
the class TestProxyAccess method setUp.
@Before
public void setUp() throws Exception {
proxyAccessCount.set(0);
this.proxyPort = findAvailablePort();
this.proxyServer = DefaultHttpProxyServer.bootstrap().withPort(proxyPort).withProxyAuthenticator(new org.littleshoot.proxy.ProxyAuthenticator() {
@Override
public boolean authenticate(String user, String pass) {
boolean isValid = user.equals(PROXY_USER) && pass.equals(PROXY_PASS);
logger.debug("Proxy Authentication: " + (isValid ? "success" : "failure"));
return isValid;
}
}).withFiltersSource(new HttpFiltersSourceAdapter() {
@Override
public HttpFilters filterRequest(HttpRequest httpRequest, ChannelHandlerContext channelHandlerContext) {
proxyAccessCount.incrementAndGet();
return super.filterRequest(httpRequest, channelHandlerContext);
}
}).start();
}
use of org.littleshoot.proxy.HttpFilters in project td-client-java by treasure-data.
the class TestSSLProxyAccess method setUp.
@Before
public void setUp() throws Exception {
proxyAccessCount.set(0);
this.proxyPort = TestProxyAccess.findAvailablePort();
this.proxyServer = DefaultHttpProxyServer.bootstrap().withPort(proxyPort).withProxyAuthenticator(new org.littleshoot.proxy.ProxyAuthenticator() {
public boolean authenticate(String user, String pass) {
boolean isValid = user.equals(PROXY_USER) && pass.equals(PROXY_PASS);
logger.debug("Proxy Authentication: " + (isValid ? "success" : "failure"));
return isValid;
}
}).withFiltersSource(new HttpFiltersSourceAdapter() {
@Override
public HttpFilters filterRequest(HttpRequest httpRequest, ChannelHandlerContext channelHandlerContext) {
proxyAccessCount.incrementAndGet();
return super.filterRequest(httpRequest, channelHandlerContext);
}
}).start();
}
Aggregations