Search in sources :

Example 1 with Headers

use of com.netflix.zuul.message.Headers in project zuul by Netflix.

the class ZuulFilterChainRunnerTest method before.

@Before
public void before() {
    SessionContext context = new SessionContext();
    Headers headers = new Headers();
    ChannelHandlerContext chc = mock(ChannelHandlerContext.class);
    when(chc.executor()).thenReturn(ImmediateEventExecutor.INSTANCE);
    context.put(NETTY_SERVER_CHANNEL_HANDLER_CONTEXT, chc);
    request = new HttpRequestMessageImpl(context, "http", "GET", "/foo/bar", new HttpQueryParams(), headers, "127.0.0.1", "http", 8080, "server123");
    request.storeInboundRequest();
    response = new HttpResponseMessageImpl(context, request, 200);
}
Also used : Headers(com.netflix.zuul.message.Headers) HttpQueryParams(com.netflix.zuul.message.http.HttpQueryParams) HttpResponseMessageImpl(com.netflix.zuul.message.http.HttpResponseMessageImpl) SessionContext(com.netflix.zuul.context.SessionContext) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Before(org.junit.Before)

Example 2 with Headers

use of com.netflix.zuul.message.Headers in project zuul by Netflix.

the class HttpUtilsTest method acceptsGzip.

@Test
public void acceptsGzip() {
    Headers headers = new Headers();
    headers.add("Accept-Encoding", "gzip, deflate");
    assertTrue(HttpUtils.acceptsGzip(headers));
}
Also used : Headers(com.netflix.zuul.message.Headers) Test(org.junit.Test)

Example 3 with Headers

use of com.netflix.zuul.message.Headers in project zuul by Netflix.

the class HttpUtilsTest method acceptsGzip_only.

@Test
public void acceptsGzip_only() {
    Headers headers = new Headers();
    headers.add("Accept-Encoding", "deflate");
    assertFalse(HttpUtils.acceptsGzip(headers));
}
Also used : Headers(com.netflix.zuul.message.Headers) Test(org.junit.Test)

Example 4 with Headers

use of com.netflix.zuul.message.Headers in project zuul by Netflix.

the class HttpUtilsTest method getBodySizeIfKnown_returnsResponseBodySize.

@Test
public void getBodySizeIfKnown_returnsResponseBodySize() {
    SessionContext context = new SessionContext();
    Headers headers = new Headers();
    HttpQueryParams queryParams = new HttpQueryParams();
    HttpRequestMessage request = new HttpRequestMessageImpl(context, "http", "GET", "/path", queryParams, headers, "127.0.0.1", "scheme", 6666, "server-name");
    request.storeInboundRequest();
    HttpResponseMessage response = new HttpResponseMessageImpl(context, request, 200);
    response.setBodyAsText("Hello world");
    assertThat(HttpUtils.getBodySizeIfKnown(response)).isEqualTo(Integer.valueOf(11));
}
Also used : HttpResponseMessage(com.netflix.zuul.message.http.HttpResponseMessage) Headers(com.netflix.zuul.message.Headers) HttpRequestMessage(com.netflix.zuul.message.http.HttpRequestMessage) HttpQueryParams(com.netflix.zuul.message.http.HttpQueryParams) HttpResponseMessageImpl(com.netflix.zuul.message.http.HttpResponseMessageImpl) SessionContext(com.netflix.zuul.context.SessionContext) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Test(org.junit.Test)

Example 5 with Headers

use of com.netflix.zuul.message.Headers in project zuul by Netflix.

the class HttpRequestMessageImplTest method getOriginalPort_EmptyXFFPort.

@Test
public void getOriginalPort_EmptyXFFPort() throws URISyntaxException {
    Headers headers = new Headers();
    headers.add(HttpHeaderNames.X_FORWARDED_PORT, "");
    // Default to using server port
    assertEquals(9999, HttpRequestMessageImpl.getOriginalPort(new SessionContext(), headers, 9999));
}
Also used : Headers(com.netflix.zuul.message.Headers) SessionContext(com.netflix.zuul.context.SessionContext) Test(org.junit.Test)

Aggregations

Headers (com.netflix.zuul.message.Headers)26 SessionContext (com.netflix.zuul.context.SessionContext)17 Test (org.junit.Test)16 HttpResponseMessageImpl (com.netflix.zuul.message.http.HttpResponseMessageImpl)5 HttpQueryParams (com.netflix.zuul.message.http.HttpQueryParams)4 HttpResponseMessage (com.netflix.zuul.message.http.HttpResponseMessage)4 InetSocketAddress (java.net.InetSocketAddress)4 HttpRequestMessage (com.netflix.zuul.message.http.HttpRequestMessage)3 HttpRequestMessageImpl (com.netflix.zuul.message.http.HttpRequestMessageImpl)3 ZuulMessage (com.netflix.zuul.message.ZuulMessage)2 ZuulMessageImpl (com.netflix.zuul.message.ZuulMessageImpl)2 HttpRequestInfo (com.netflix.zuul.message.http.HttpRequestInfo)2 ByteBuf (io.netty.buffer.ByteBuf)2 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)2 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)2 SocketAddress (java.net.SocketAddress)2 Map (java.util.Map)2 Before (org.junit.Before)2 ClientException (com.netflix.client.ClientException)1 CompleteEvent (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteEvent)1