Search in sources :

Example 6 with AsciiString

use of io.netty.util.AsciiString 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.Test)

Example 7 with AsciiString

use of io.netty.util.AsciiString 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.Test)

Example 8 with AsciiString

use of io.netty.util.AsciiString 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.Test)

Example 9 with AsciiString

use of io.netty.util.AsciiString in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testAuthorityFormRequestTargetHandled.

@Test
public void testAuthorityFormRequestTargetHandled() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, CONNECT, "http://www.example.com:80");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("CONNECT")).path(new AsciiString("/")).scheme(new AsciiString("http")).authority(new AsciiString("www.example.com: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.Test)

Example 10 with AsciiString

use of io.netty.util.AsciiString in project netty by netty.

the class HttpToHttp2ConnectionHandlerTest method testHeadersOnlyRequest.

@Test
public void testHeadersOnlyRequest() throws Exception {
    bootstrapEnv(2, 1, 0);
    final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http://my-user_name@www.example.org:5555/example");
    final HttpHeaders httpHeaders = request.headers();
    httpHeaders.setInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), 5);
    httpHeaders.set(HttpHeaderNames.HOST, "my-user_name@www.example.org:5555");
    httpHeaders.set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http");
    httpHeaders.add(of("foo"), of("goo"));
    httpHeaders.add(of("foo"), of("goo2"));
    httpHeaders.add(of("foo2"), of("goo2"));
    final Http2Headers http2Headers = new DefaultHttp2Headers().method(new AsciiString("GET")).path(new AsciiString("/example")).authority(new AsciiString("www.example.org:5555")).scheme(new AsciiString("http")).add(new AsciiString("foo"), new AsciiString("goo")).add(new AsciiString("foo"), new AsciiString("goo2")).add(new AsciiString("foo2"), new AsciiString("goo2"));
    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.Test)

Aggregations

AsciiString (io.netty.util.AsciiString)73 Test (org.junit.Test)43 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)27 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)26 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)25 ByteBuf (io.netty.buffer.ByteBuf)18 ChannelPromise (io.netty.channel.ChannelPromise)15 DefaultHttp2Headers (io.netty.handler.codec.http2.DefaultHttp2Headers)12 Http2CodecUtil.getEmbeddedHttp2Exception (io.netty.handler.codec.http2.Http2CodecUtil.getEmbeddedHttp2Exception)12 Http2Runnable (io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable)12 FullHttpMessage (io.netty.handler.codec.http.FullHttpMessage)11 Http2Headers (io.netty.handler.codec.http2.Http2Headers)9 Metadata (io.grpc.Metadata)8 ChannelFuture (io.netty.channel.ChannelFuture)4 Status (io.grpc.Status)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Setup (org.openjdk.jmh.annotations.Setup)3 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)2