use of io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2RequestHeaders 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]);
}
use of io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2RequestHeaders in project grpc-java by grpc.
the class GrpcHttp2InboundHeadersTest method basicCorrectness.
@Test
public void basicCorrectness() {
Http2Headers headers = new GrpcHttp2RequestHeaders(1);
headers.add(of(":method"), of("POST"));
headers.add(of("content-type"), of("application/grpc+proto"));
headers.add(of(":path"), of("/google.pubsub.v2.PublisherService/CreateTopic"));
headers.add(of(":scheme"), of("https"));
headers.add(of("te"), of("trailers"));
headers.add(of(":authority"), of("pubsub.googleapis.com"));
headers.add(of("foo"), of("bar"));
assertEquals(7, headers.size());
// Number of headers without the pseudo headers and 'te' header.
assertEquals(2, ((GrpcHttp2InboundHeaders) headers).numHeaders());
assertEquals(of("application/grpc+proto"), headers.get(of("content-type")));
assertEquals(of("/google.pubsub.v2.PublisherService/CreateTopic"), headers.path());
assertEquals(of("https"), headers.scheme());
assertEquals(of("POST"), headers.method());
assertEquals(of("pubsub.googleapis.com"), headers.authority());
assertEquals(of("trailers"), headers.get(of("te")));
assertEquals(of("bar"), headers.get(of("foo")));
}
Aggregations