Search in sources :

Example 6 with HttpRequestMessageImpl

use of com.netflix.zuul.message.http.HttpRequestMessageImpl in project zuul by Netflix.

the class ClientRequestReceiverTest method parseUriFromNetty_unknown.

@Test
public void parseUriFromNetty_unknown() {
    EmbeddedChannel channel = new EmbeddedChannel(new ClientRequestReceiver(null));
    channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
    HttpRequestMessageImpl result;
    {
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "asdf", Unpooled.buffer()));
        result = channel.readInbound();
        result.disposeBufferedBody();
    }
    assertEquals("asdf", result.getPath());
    channel.close();
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Test(org.junit.Test)

Example 7 with HttpRequestMessageImpl

use of com.netflix.zuul.message.http.HttpRequestMessageImpl in project zuul by Netflix.

the class ClientRequestReceiverTest method parseQueryParamsWithEncodedCharsInURI.

@Test
public void parseQueryParamsWithEncodedCharsInURI() {
    EmbeddedChannel channel = new EmbeddedChannel(new ClientRequestReceiver(null));
    channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
    HttpRequestMessageImpl result;
    {
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/foo/bar/somePath/%5E1.0.0?param1=foo&param2=bar&param3=baz", Unpooled.buffer()));
        result = channel.readInbound();
        result.disposeBufferedBody();
    }
    assertEquals("foo", result.getQueryParams().getFirst("param1"));
    assertEquals("bar", result.getQueryParams().getFirst("param2"));
    assertEquals("baz", result.getQueryParams().getFirst("param3"));
    channel.close();
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Test(org.junit.Test)

Example 8 with HttpRequestMessageImpl

use of com.netflix.zuul.message.http.HttpRequestMessageImpl in project zuul by Netflix.

the class ClientRequestReceiverTest method largeResponse_atLimit.

@Test
public void largeResponse_atLimit() {
    ClientRequestReceiver receiver = new ClientRequestReceiver(null);
    EmbeddedChannel channel = new EmbeddedChannel(receiver);
    // Required for messages
    channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
    int maxSize;
    // Figure out the max size, since it isn't public.
    {
        ByteBuf buf = Unpooled.buffer(1).writeByte('a');
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/post", buf));
        HttpRequestMessageImpl res = channel.readInbound();
        maxSize = res.getMaxBodySize();
        res.disposeBufferedBody();
    }
    HttpRequestMessageImpl result;
    {
        ByteBuf buf = Unpooled.buffer(maxSize);
        buf.writerIndex(maxSize);
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/post", buf));
        result = channel.readInbound();
        result.disposeBufferedBody();
    }
    assertNull(result.getContext().getError());
    assertFalse(result.getContext().shouldSendErrorResponse());
    channel.close();
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 9 with HttpRequestMessageImpl

use of com.netflix.zuul.message.http.HttpRequestMessageImpl in project zuul by Netflix.

the class ClientRequestReceiverTest method parseUriFromNetty_relative.

@Test
public void parseUriFromNetty_relative() {
    EmbeddedChannel channel = new EmbeddedChannel(new ClientRequestReceiver(null));
    channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
    HttpRequestMessageImpl result;
    {
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/foo/bar/somePath/%5E1.0.0?param1=foo&param2=bar&param3=baz", Unpooled.buffer()));
        result = channel.readInbound();
        result.disposeBufferedBody();
    }
    assertEquals("/foo/bar/somePath/%5E1.0.0", result.getPath());
    channel.close();
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Test(org.junit.Test)

Example 10 with HttpRequestMessageImpl

use of com.netflix.zuul.message.http.HttpRequestMessageImpl in project zuul by Netflix.

the class ClientRequestReceiverTest method parseUriFromNetty_absolute.

@Test
public void parseUriFromNetty_absolute() {
    EmbeddedChannel channel = new EmbeddedChannel(new ClientRequestReceiver(null));
    channel.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).set(1234);
    HttpRequestMessageImpl result;
    {
        channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "https://www.netflix.com/foo/bar/somePath/%5E1.0.0?param1=foo&param2=bar&param3=baz", Unpooled.buffer()));
        result = channel.readInbound();
        result.disposeBufferedBody();
    }
    assertEquals("/foo/bar/somePath/%5E1.0.0", result.getPath());
    channel.close();
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpRequestMessageImpl(com.netflix.zuul.message.http.HttpRequestMessageImpl) Test(org.junit.Test)

Aggregations

HttpRequestMessageImpl (com.netflix.zuul.message.http.HttpRequestMessageImpl)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)8 Test (org.junit.Test)8 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)7 SessionContext (com.netflix.zuul.context.SessionContext)3 ByteBuf (io.netty.buffer.ByteBuf)3 Headers (com.netflix.zuul.message.Headers)2 HttpQueryParams (com.netflix.zuul.message.http.HttpQueryParams)2 HttpRequestMessage (com.netflix.zuul.message.http.HttpRequestMessage)2 HttpResponseMessageImpl (com.netflix.zuul.message.http.HttpResponseMessageImpl)2 InetSocketAddress (java.net.InetSocketAddress)2 SslHandshakeInfo (com.netflix.netty.common.ssl.SslHandshakeInfo)1 HttpResponseMessage (com.netflix.zuul.message.http.HttpResponseMessage)1 Channel (io.netty.channel.Channel)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 SocketAddress (java.net.SocketAddress)1 Before (org.junit.Before)1