Search in sources :

Example 1 with GrpcHttp2InboundHeaders

use of io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2InboundHeaders in project grpc-java by grpc.

the class GrpcHttp2InboundHeadersTest method binaryHeadersShouldBeBase64Decoded.

@Test
public void binaryHeadersShouldBeBase64Decoded() {
    Http2Headers headers = new GrpcHttp2RequestHeaders(1);
    byte[] data = new byte[100];
    new Random().nextBytes(data);
    headers.add(of("foo-bin"), of(BaseEncoding.base64().encode(data)));
    assertEquals(1, headers.size());
    byte[][] namesAndValues = ((GrpcHttp2InboundHeaders) headers).namesAndValues();
    assertEquals(of("foo-bin"), new AsciiString(namesAndValues[0]));
    assertNotSame(data, namesAndValues[1]);
    assertArrayEquals(data, namesAndValues[1]);
}
Also used : Random(java.util.Random) Http2Headers(io.netty.handler.codec.http2.Http2Headers) GrpcHttp2RequestHeaders(io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2RequestHeaders) GrpcHttp2InboundHeaders(io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2InboundHeaders) AsciiString(io.netty.util.AsciiString) Test(org.junit.Test)

Aggregations

GrpcHttp2InboundHeaders (io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2InboundHeaders)1 GrpcHttp2RequestHeaders (io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2RequestHeaders)1 Http2Headers (io.netty.handler.codec.http2.Http2Headers)1 AsciiString (io.netty.util.AsciiString)1 Random (java.util.Random)1 Test (org.junit.Test)1