@Test public void convertClientHeaders_sanitizes() { Metadata metaData = new Metadata(); metaData.put(GrpcUtil.CONTENT_TYPE_KEY, "to-be-removed"); metaData.put(GrpcUtil.USER_AGENT_KEY, "to-be-removed"); metaData.put(GrpcUtil.TE_HEADER, "to-be-removed"); metaData.put(userKey, userValue); String scheme = "https"; String userAgent = "user-agent"; String method = "POST"; String authority = "authority"; String path = " Http2Headers output = Utils.convertClientHeaders( metaData, new AsciiString(scheme), new AsciiString(path), new AsciiString(authority), new AsciiString(method), new AsciiString(userAgent)); DefaultHttp2Headers headers = new DefaultHttp2Headers(); for (Map.Entry<CharSequence, CharSequence> entry : output) { headers.add(entry.getKey(), entry.getValue()); } assertEquals(7 + 1, headers.size()); assertEquals(GrpcUtil.CONTENT_TYPE_GRPC, headers.get(GrpcUtil.CONTENT_TYPE_KEY.name()).toString()); assertEquals(userAgent, headers.get(GrpcUtil.USER_AGENT_KEY.name()).toString()); assertEquals(GrpcUtil.TE_TRAILERS, headers.get(GrpcUtil.TE_HEADER.name()).toString()); assertEquals(userValue, headers.get(userKey.name()).toString()); }
public static Http2Headers convertClientHeaders(Metadata headers, AsciiString scheme, AsciiString defaultPath, AsciiString authority, AsciiString method, AsciiString userAgent) { Preconditions.checkNotNull(defaultPath, "defaultPath"); Preconditions.checkNotNull(authority, "authority"); Preconditions.checkNotNull(method, "method"); headers.discardAll(CONTENT_TYPE_KEY); headers.discardAll(GrpcUtil.TE_HEADER); headers.discardAll(GrpcUtil.USER_AGENT_KEY); return GrpcHttp2OutboundHeaders.clientRequestHeaders( toHttp2Headers(headers), authority, defaultPath, method, scheme, userAgent); }
Utils { public static Http2Headers convertClientHeaders(Metadata headers, AsciiString scheme, AsciiString defaultPath, AsciiString authority, AsciiString method, AsciiString userAgent) { Preconditions.checkNotNull(defaultPath, "defaultPath"); Preconditions.checkNotNull(authority, "authority"); Preconditions.checkNotNull(method, "method"); headers.discardAll(CONTENT_TYPE_KEY); headers.discardAll(GrpcUtil.TE_HEADER); headers.discardAll(GrpcUtil.USER_AGENT_KEY); return GrpcHttp2OutboundHeaders.clientRequestHeaders( toHttp2Headers(headers), authority, defaultPath, method, scheme, userAgent); } }
Utils { public static Http2Headers convertClientHeaders(Metadata headers, AsciiString scheme, AsciiString defaultPath, AsciiString authority, AsciiString method, AsciiString userAgent) { Preconditions.checkNotNull(defaultPath, "defaultPath"); Preconditions.checkNotNull(authority, "authority"); Preconditions.checkNotNull(method, "method"); headers.discardAll(CONTENT_TYPE_KEY); headers.discardAll(GrpcUtil.TE_HEADER); headers.discardAll(GrpcUtil.USER_AGENT_KEY); return GrpcHttp2OutboundHeaders.clientRequestHeaders( toHttp2Headers(headers), authority, defaultPath, method, scheme, userAgent); } private  Utils(); }
Utils { public static Http2Headers convertClientHeaders(Metadata headers, AsciiString scheme, AsciiString defaultPath, AsciiString authority, AsciiString method, AsciiString userAgent) { Preconditions.checkNotNull(defaultPath, "defaultPath"); Preconditions.checkNotNull(authority, "authority"); Preconditions.checkNotNull(method, "method"); headers.discardAll(CONTENT_TYPE_KEY); headers.discardAll(GrpcUtil.TE_HEADER); headers.discardAll(GrpcUtil.USER_AGENT_KEY); return GrpcHttp2OutboundHeaders.clientRequestHeaders( toHttp2Headers(headers), authority, defaultPath, method, scheme, userAgent); } private  Utils(); static Metadata convertHeaders(Http2Headers http2Headers); static Http2Headers convertClientHeaders(Metadata headers,
      AsciiString scheme,
      AsciiString defaultPath,
      AsciiString authority,
      AsciiString method,
      AsciiString userAgent); static Http2Headers convertServerHeaders(Metadata headers); static Metadata convertTrailers(Http2Headers http2Headers); static Http2Headers convertTrailers(Metadata trailers, boolean headersSent); static Status statusFromThrowable(Throwable t); }
Utils { public static Http2Headers convertClientHeaders(Metadata headers, AsciiString scheme, AsciiString defaultPath, AsciiString authority, AsciiString method, AsciiString userAgent) { Preconditions.checkNotNull(defaultPath, "defaultPath"); Preconditions.checkNotNull(authority, "authority"); Preconditions.checkNotNull(method, "method"); headers.discardAll(CONTENT_TYPE_KEY); headers.discardAll(GrpcUtil.TE_HEADER); headers.discardAll(GrpcUtil.USER_AGENT_KEY); return GrpcHttp2OutboundHeaders.clientRequestHeaders( toHttp2Headers(headers), authority, defaultPath, method, scheme, userAgent); } private  Utils(); static Metadata convertHeaders(Http2Headers http2Headers); static Http2Headers convertClientHeaders(Metadata headers,
      AsciiString scheme,
      AsciiString defaultPath,
      AsciiString authority,
      AsciiString method,
      AsciiString userAgent); static Http2Headers convertServerHeaders(Metadata headers); static Metadata convertTrailers(Http2Headers http2Headers); static Http2Headers convertTrailers(Metadata trailers, boolean headersSent); static Status statusFromThrowable(Throwable t); static final AsciiString STATUS_OK; static final AsciiString HTTP_METHOD; static final AsciiString HTTP_GET_METHOD; static final AsciiString HTTPS; static final AsciiString HTTP; static final AsciiString CONTENT_TYPE_HEADER; static final AsciiString CONTENT_TYPE_GRPC; static final AsciiString TE_HEADER; static final AsciiString TE_TRAILERS; static final AsciiString USER_AGENT; static final Resource<EventLoopGroup> DEFAULT_BOSS_EVENT_LOOP_GROUP; static final Resource<EventLoopGroup> DEFAULT_WORKER_EVENT_LOOP_GROUP; }