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));
}
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"));
}
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"));
}
Aggregations