Search in sources :

Example 6 with GrpcHttp2RequestHeaders

use of io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders in project grpc-java by grpc.

the class GrpcHttp2HeadersUtilsTest method dupBinHeadersWithComma.

@Test
public void dupBinHeadersWithComma() {
    Key<byte[]> key = Key.of("bytes-bin", BINARY_BYTE_MARSHALLER);
    Http2Headers http2Headers = new GrpcHttp2RequestHeaders(2);
    http2Headers.add(AsciiString.of("bytes-bin"), AsciiString.of("BaS,e6,,4+,padding=="));
    http2Headers.add(AsciiString.of("bytes-bin"), AsciiString.of("more"));
    http2Headers.add(AsciiString.of("bytes-bin"), AsciiString.of(""));
    Metadata recoveredHeaders = Utils.convertHeaders(http2Headers);
    byte[][] values = Iterables.toArray(recoveredHeaders.getAll(key), byte[].class);
    assertTrue(Arrays.deepEquals(new byte[][] { BaseEncoding.base64().decode("BaS"), BaseEncoding.base64().decode("e6"), BaseEncoding.base64().decode(""), BaseEncoding.base64().decode("4+"), BaseEncoding.base64().decode("padding"), BaseEncoding.base64().decode("more"), BaseEncoding.base64().decode("") }, values));
}
Also used : Http2Headers(io.netty.handler.codec.http2.Http2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) GrpcHttp2RequestHeaders(io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders) Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 7 with GrpcHttp2RequestHeaders

use of io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders in project grpc-java by grpc.

the class GrpcHttp2HeadersUtilsTest method headerSetLong.

@Test
public void headerSetLong() {
    // setLong is used by Netty 4.1.60+. https://github.com/grpc/grpc-java/issues/7953
    Http2Headers http2Headers = new GrpcHttp2RequestHeaders(2);
    http2Headers.add(AsciiString.of("long-header"), AsciiString.of("1"));
    http2Headers.add(AsciiString.of("long-header"), AsciiString.of("2"));
    http2Headers.setLong(AsciiString.of("long-header"), 3);
    assertThat(http2Headers.size()).isEqualTo(1);
    assertThat(http2Headers.getAll(AsciiString.of("long-header"))).containsExactly(AsciiString.of("3"));
}
Also used : Http2Headers(io.netty.handler.codec.http2.Http2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) GrpcHttp2RequestHeaders(io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders) Test(org.junit.Test)

Example 8 with GrpcHttp2RequestHeaders

use of io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders in project grpc-java by grpc.

the class GrpcHttp2HeadersUtilsTest method headerRemove_notPresent.

@Test
public void headerRemove_notPresent() {
    Http2Headers http2Headers = new GrpcHttp2RequestHeaders(2);
    http2Headers.add(AsciiString.of("dont-care"), AsciiString.of("value"));
    assertThat(http2Headers.remove(AsciiString.of("not-seen"))).isFalse();
    assertThat(http2Headers.size()).isEqualTo(1);
    assertThat(http2Headers.getAll(AsciiString.of("dont-care"))).containsExactly(AsciiString.of("value"));
}
Also used : Http2Headers(io.netty.handler.codec.http2.Http2Headers) DefaultHttp2Headers(io.netty.handler.codec.http2.DefaultHttp2Headers) GrpcHttp2RequestHeaders(io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders) Test(org.junit.Test)

Aggregations

GrpcHttp2RequestHeaders (io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders)8 Http2Headers (io.netty.handler.codec.http2.Http2Headers)8 Test (org.junit.Test)8 DefaultHttp2Headers (io.netty.handler.codec.http2.DefaultHttp2Headers)6 Metadata (io.grpc.Metadata)1 GrpcHttp2InboundHeaders (io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2InboundHeaders)1 AsciiString (io.netty.util.AsciiString)1 Random (java.util.Random)1