Search in sources :

Example 61 with FullHttpRequest

use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testOriginFormRequestTargetHandledFromUrlencodedUri.

@Test
public void testOriginFormRequestTargetHandledFromUrlencodedUri() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/where%2B0?q=now%2B0&f=then%2B0#section1%2B0");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http");
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/where%2B0?q=now%2B0&f=then%2B0#section1%2B0")).scheme(new AsciiString("http"));
    ChannelPromise writePromise = newPromise();
    verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) AsciiString(io.netty.util.AsciiString) ChannelPromise(io.netty.channel.ChannelPromise) Test(org.junit.jupiter.api.Test)

Example 62 with FullHttpRequest

use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testAbsoluteFormRequestTargetHandledFromHeaders.

@Test
public void testAbsoluteFormRequestTargetHandledFromHeaders() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/pub/WWW/TheProject.html");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    httpHeaders.set(HttpHeaderNames.HOST, "foouser@www.example.org:5555");
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.PATH.text(), "ignored_path");
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "https");
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/pub/WWW/TheProject.html")).authority(new AsciiString("www.example.org:5555")).scheme(new AsciiString("https"));
    ChannelPromise writePromise = newPromise();
    verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) AsciiString(io.netty.util.AsciiString) ChannelPromise(io.netty.channel.ChannelPromise) Test(org.junit.jupiter.api.Test)

Example 63 with FullHttpRequest

use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testAbsoluteFormRequestTargetHandledFromRequestTargetUri.

@Test
public void testAbsoluteFormRequestTargetHandledFromRequestTargetUri() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http://foouser@www.example.org:5555/pub/WWW/TheProject.html");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/pub/WWW/TheProject.html")).authority(new AsciiString("www.example.org:5555")).scheme(new AsciiString("http"));
    ChannelPromise writePromise = newPromise();
    verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) AsciiString(io.netty.util.AsciiString) ChannelPromise(io.netty.channel.ChannelPromise) Test(org.junit.jupiter.api.Test)

Example 64 with FullHttpRequest

use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testHostIPv4FormRequestTargetHandled.

@Test
public void testHostIPv4FormRequestTargetHandled() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    httpHeaders.set(HttpHeaderNames.HOST, "1.2.3.4:80");
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http");
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/")).scheme(new AsciiString("http")).authority(new AsciiString("1.2.3.4:80"));
    ChannelPromise writePromise = newPromise();
    verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) AsciiString(io.netty.util.AsciiString) ChannelPromise(io.netty.channel.ChannelPromise) Test(org.junit.jupiter.api.Test)

Example 65 with FullHttpRequest

use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testHostIPv6FormRequestTargetHandled.

@Test
public void testHostIPv6FormRequestTargetHandled() throws Exception {
    // Valid according to
    // https://tools.ietf.org/html/rfc7230#section-2.7.1 -> https://tools.ietf.org/html/rfc3986#section-3.2.2
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    httpHeaders.set(HttpHeaderNames.HOST, "[::1]:80");
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http");
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/")).scheme(new AsciiString("http")).authority(new AsciiString("[::1]:80"));
    ChannelPromise writePromise = newPromise();
    verifyHeadersOnly(http2Headers, writePromise, clientChannel.writeAndFlush(request, writePromise));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) AsciiString(io.netty.util.AsciiString) ChannelPromise(io.netty.channel.ChannelPromise) Test(org.junit.jupiter.api.Test)

Aggregations

FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)287 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)180 Test (org.junit.jupiter.api.Test)74 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)69 Test (org.junit.Test)64 ByteBuf (io.netty.buffer.ByteBuf)54 HttpResponse (io.netty.handler.codec.http.HttpResponse)49 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)43 URI (java.net.URI)35 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)31 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)30 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)30 AsciiString (io.netty.util.AsciiString)25 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)23 Map (java.util.Map)22 ChannelPromise (io.netty.channel.ChannelPromise)21 HttpMethod (io.netty.handler.codec.http.HttpMethod)20 IOException (java.io.IOException)19 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)18 ResponseParts (com.github.ambry.rest.NettyClient.ResponseParts)16