Search in sources :

Example 76 with HttpHeaders

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

the class HttpConversionUtilTest method stripConnectionHeadersAndNominees.

@Test
public void stripConnectionHeadersAndNominees() {
    HttpHeaders inHeaders = new DefaultHttpHeaders();
    inHeaders.add(CONNECTION, "foo");
    inHeaders.add("foo", "bar");
    Http2Headers out = new DefaultHttp2Headers();
    HttpConversionUtil.toHttp2Headers(inHeaders, out);
    assertTrue(out.isEmpty());
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) Test(org.junit.jupiter.api.Test)

Example 77 with HttpHeaders

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

the class HttpConversionUtilTest method connectionSpecificHeadersShouldBeRemoved.

@Test
public void connectionSpecificHeadersShouldBeRemoved() {
    HttpHeaders inHeaders = new DefaultHttpHeaders();
    inHeaders.add(CONNECTION, "keep-alive");
    inHeaders.add(HOST, "example.com");
    @SuppressWarnings("deprecation") AsciiString keepAlive = KEEP_ALIVE;
    inHeaders.add(keepAlive, "timeout=5, max=1000");
    @SuppressWarnings("deprecation") AsciiString proxyConnection = PROXY_CONNECTION;
    inHeaders.add(proxyConnection, "timeout=5, max=1000");
    inHeaders.add(TRANSFER_ENCODING, "chunked");
    inHeaders.add(UPGRADE, "h2c");
    Http2Headers outHeaders = new DefaultHttp2Headers();
    HttpConversionUtil.toHttp2Headers(inHeaders, outHeaders);
    assertFalse(outHeaders.contains(CONNECTION));
    assertFalse(outHeaders.contains(HOST));
    assertFalse(outHeaders.contains(keepAlive));
    assertFalse(outHeaders.contains(proxyConnection));
    assertFalse(outHeaders.contains(TRANSFER_ENCODING));
    assertFalse(outHeaders.contains(UPGRADE));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) AsciiString(io.netty.util.AsciiString) Test(org.junit.jupiter.api.Test)

Example 78 with HttpHeaders

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

the class HttpConversionUtilTest method stripTEHeadersExcludingTrailers.

@Test
public void stripTEHeadersExcludingTrailers() {
    HttpHeaders inHeaders = new DefaultHttpHeaders();
    inHeaders.add(TE, GZIP);
    inHeaders.add(TE, TRAILERS);
    Http2Headers out = new DefaultHttp2Headers();
    HttpConversionUtil.toHttp2Headers(inHeaders, out);
    assertSame(TRAILERS, out.get(TE));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) Test(org.junit.jupiter.api.Test)

Example 79 with HttpHeaders

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

the class HttpConversionUtilTest method addHttp2ToHttpHeadersCombinesCookies.

@Test
public void addHttp2ToHttpHeadersCombinesCookies() throws Http2Exception {
    Http2Headers inHeaders = new DefaultHttp2Headers();
    inHeaders.add("yes", "no");
    inHeaders.add(COOKIE, "foo=bar");
    inHeaders.add(COOKIE, "bax=baz");
    HttpHeaders outHeaders = new DefaultHttpHeaders();
    HttpConversionUtil.addHttp2ToHttpHeaders(5, inHeaders, outHeaders, HttpVersion.HTTP_1_1, false, false);
    assertEquals("no", outHeaders.get("yes"));
    assertEquals("foo=bar; bax=baz", outHeaders.get(COOKIE.toString()));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) Test(org.junit.jupiter.api.Test)

Example 80 with HttpHeaders

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

the class HttpConversionUtilTest method http2ToHttpHeaderTest.

@Test
public void http2ToHttpHeaderTest() throws Exception {
    Http2Headers http2Headers = new DefaultHttp2Headers();
    http2Headers.status("200");
    // HTTP/2 Header response should not contain 'path' in response.
    http2Headers.path("/meow");
    http2Headers.set("cat", "meow");
    HttpHeaders httpHeaders = new DefaultHttpHeaders();
    HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, true);
    assertFalse(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text()));
    assertEquals("meow", httpHeaders.get("cat"));
    httpHeaders.clear();
    HttpConversionUtil.addHttp2ToHttpHeaders(3, http2Headers, httpHeaders, HttpVersion.HTTP_1_1, false, false);
    assertTrue(httpHeaders.contains(HttpConversionUtil.ExtensionHeaderNames.PATH.text()));
    assertEquals("meow", httpHeaders.get("cat"));
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) Test(org.junit.jupiter.api.Test)

Aggregations

HttpHeaders (io.netty.handler.codec.http.HttpHeaders)286 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)149 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)83 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)73 Test (org.junit.Test)68 Test (org.junit.jupiter.api.Test)57 Test (org.testng.annotations.Test)51 HttpRequest (io.netty.handler.codec.http.HttpRequest)43 HttpResponse (io.netty.handler.codec.http.HttpResponse)40 AsciiString (io.netty.util.AsciiString)29 ByteBuf (io.netty.buffer.ByteBuf)27 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)27 BStruct (org.ballerinalang.model.values.BStruct)26 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)22 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)22 HttpServletResponse (javax.servlet.http.HttpServletResponse)20 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)19 Cookie (io.netty.handler.codec.http.cookie.Cookie)19 BValue (org.ballerinalang.model.values.BValue)19 ChannelPromise (io.netty.channel.ChannelPromise)18