use of io.netty.handler.codec.http.HttpHeaders in project tesla by linking12.
the class HttpFiltersRunner method createResponse.
private HttpResponse createResponse(HttpResponseStatus httpResponseStatus, HttpRequest originalRequest) {
HttpHeaders httpHeaders = new DefaultHttpHeaders();
httpHeaders.add("Transfer-Encoding", "chunked");
HttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, httpResponseStatus);
httpResponse.headers().add(httpHeaders);
return httpResponse;
}
use of io.netty.handler.codec.http.HttpHeaders in project tesla by linking12.
the class ClientToProxyConnection method modifyRequestHeadersToReflectProxying.
private void modifyRequestHeadersToReflectProxying(HttpRequest httpRequest) {
LOG.debug("Modifying request headers for proxying");
HttpHeaders headers = httpRequest.headers();
ProxyUtils.removeSdchEncoding(headers);
switchProxyConnectionHeader(headers);
stripConnectionTokens(headers);
stripHopByHopHeaders(headers);
ProxyUtils.addVia(httpRequest, proxyServer.getProxyAlias());
}
use of io.netty.handler.codec.http.HttpHeaders in project tesla by linking12.
the class ClientToProxyConnection method modifyResponseHeadersToReflectProxying.
private void modifyResponseHeadersToReflectProxying(HttpResponse httpResponse) {
if (!proxyServer.isTransparent()) {
HttpHeaders headers = httpResponse.headers();
stripConnectionTokens(headers);
stripHopByHopHeaders(headers);
ProxyUtils.addVia(httpResponse, proxyServer.getProxyAlias());
if (!headers.contains(HttpHeaderNames.DATE)) {
headers.set(HttpHeaderNames.DATE, new Date());
}
}
}
use of io.netty.handler.codec.http.HttpHeaders in project janusgraph by JanusGraph.
the class SaslAndHMACAuthenticationHandlerTest method testHttpChannelReadWhenAuthenticatorHasBeenAdded.
@Test
public void testHttpChannelReadWhenAuthenticatorHasBeenAdded() throws Exception {
final SaslAndHMACAuthenticator authenticator = createMock(SaslAndHMACAuthenticator.class);
final HMACAuthenticator hmacAuth = createMock(HMACAuthenticator.class);
final ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class);
final ChannelHandler mockHandler = createMock(ChannelHandler.class);
final ChannelPipeline pipeline = createMock(ChannelPipeline.class);
final HttpMessage msg = createMock(HttpMessage.class);
final HttpHeaders headers = createMock(HttpHeaders.class);
expect(authenticator.getHMACAuthenticator()).andReturn(hmacAuth);
expect(authenticator.getSimpleAuthenticator()).andReturn(createMock(JanusGraphSimpleAuthenticator.class));
expect(ctx.pipeline()).andReturn(pipeline);
expect(pipeline.get("hmac_authenticator")).andReturn(mockHandler);
expect(msg.headers()).andReturn(headers).times(2);
expect(headers.get(isA(String.class))).andReturn(null).times(2);
expect(ctx.fireChannelRead(eq(msg))).andReturn(ctx);
replayAll();
final SaslAndHMACAuthenticationHandler handler = new SaslAndHMACAuthenticationHandler(authenticator, null);
handler.channelRead(ctx, msg);
}
use of io.netty.handler.codec.http.HttpHeaders in project janusgraph by JanusGraph.
the class HttpHMACAuthenticationHandlerTest method testChannelReadBasicAuthIncorrectScheme.
@Test
public void testChannelReadBasicAuthIncorrectScheme() {
final ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class);
final FullHttpRequest msg = createMock(FullHttpRequest.class);
final HttpHeaders headers = createMock(HttpHeaders.class);
final Authenticator authenticator = createMock(Authenticator.class);
final ChannelFuture cf = createMock(ChannelFuture.class);
expect(msg.getMethod()).andReturn(HttpMethod.POST);
expect(msg.headers()).andReturn(headers).anyTimes();
expect(headers.get("Authorization")).andReturn("bogus");
expect(ctx.writeAndFlush(eqHttpStatus(UNAUTHORIZED))).andReturn(cf);
expect(cf.addListener(ChannelFutureListener.CLOSE)).andReturn(null);
expect(msg.release()).andReturn(false);
final HttpHMACAuthenticationHandler handler = new HttpHMACAuthenticationHandler(authenticator);
replayAll();
handler.channelRead(ctx, (Object) msg);
verifyAll();
}
Aggregations