use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project selenium_java by sergueik.
the class UtilsTest method whenRequestedTypeIsNotHTMLThenNotChangingURLRequest.
@Test
public void whenRequestedTypeIsNotHTMLThenNotChangingURLRequest() throws URISyntaxException {
URI uri = new URI("http://tenniskafe.com");
HttpHeaders httpHeaders = mock(HttpHeaders.class);
when(httpHeaders.get("Accept")).thenReturn("application/json");
HttpRequest httpRequest = mock(HttpRequest.class);
when(httpRequest.getUri()).thenReturn("http://google.com");
when(httpRequest.headers()).thenReturn(httpHeaders);
assertFalse(Utils.isUrlChangingRequest(uri, httpRequest));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project selenium_java by sergueik.
the class UtilsTest method whenTheHostIsTheSameThenNotChangingURLRequest.
@Test
public void whenTheHostIsTheSameThenNotChangingURLRequest() throws URISyntaxException {
URI uri = new URI("http://tenniskafe.com");
HttpHeaders httpHeaders = mock(HttpHeaders.class);
when(httpHeaders.get("Accept")).thenReturn("application/json");
HttpRequest httpRequest = mock(HttpRequest.class);
when(httpRequest.getUri()).thenReturn("http://tenniskafe.com/atp");
when(httpRequest.headers()).thenReturn(httpHeaders);
assertFalse(Utils.isUrlChangingRequest(uri, httpRequest));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project xian by happyyangyuan.
the class RequestDecoderAux method decode.
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception {
LOG.debug(" httpRequest ----> UnitRequest Pojo");
/*if (!HttpMethod.POST.equals(msg.method())) {
throw new BadRequestException(new IllegalArgumentException("拒绝非POST请求!"));
}*/
DecoderResult result = msg.decoderResult();
if (!result.isSuccess()) {
throw new BadRequestException(result.cause());
}
updateLongConnectionStatus(msg, ctx);
Request request = new Request(msg, MsgIdHolder.get());
offerReqQueue(ctx, request);
out.add(request);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project incubator-pulsar by apache.
the class BrokerServiceLookupTest method getHttpClient.
private AsyncHttpClient getHttpClient(String version) {
DefaultAsyncHttpClientConfig.Builder confBuilder = new DefaultAsyncHttpClientConfig.Builder();
confBuilder.setFollowRedirect(true);
confBuilder.setUserAgent(version);
confBuilder.setKeepAliveStrategy(new DefaultKeepAliveStrategy() {
@Override
public boolean keepAlive(Request ahcRequest, HttpRequest request, HttpResponse response) {
// Close connection upon a server error or per HTTP spec
return (response.status().code() / 100 != 5) && super.keepAlive(ahcRequest, request, response);
}
});
AsyncHttpClientConfig config = confBuilder.build();
return new DefaultAsyncHttpClient(config);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project jbossws-cxf by jbossws.
the class HTTPProxyTestCaseForked method initProxyServer.
private void initProxyServer() throws Exception {
org.littleshoot.proxy.ProxyAuthenticator proxyAuthenticator = new org.littleshoot.proxy.ProxyAuthenticator() {
@Override
public boolean authenticate(String user, String pwd) {
return (PROXY_USER.equals(user) && PROXY_PWD.equals(pwd));
}
};
InetSocketAddress address = new InetSocketAddress(getServerHost(), ++proxyPort);
ChainedProxyManager chainProxyManager = new ChainedProxyManager() {
@Override
public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
chainedProxies.add(new ChainedProxyAdapter() {
@Override
public InetSocketAddress getChainedProxyAddress() {
return new InetSocketAddress(getServerHost(), getServerPort());
}
});
}
};
proxyServer = org.littleshoot.proxy.impl.DefaultHttpProxyServer.bootstrap().withChainProxyManager(chainProxyManager).withAddress(address).withProxyAuthenticator(proxyAuthenticator).start();
}
Aggregations