@Test public void invalidInboundContentTypeShouldCancelStream() { stream().transportState().setId(STREAM_ID); Http2Headers headers = new DefaultHttp2Headers().status(STATUS_OK).set(CONTENT_TYPE_HEADER, new AsciiString("application/bad", UTF_8)); stream().transportState().transportHeadersReceived(headers, false); Http2Headers trailers = new DefaultHttp2Headers() .set(new AsciiString("grpc-status", UTF_8), new AsciiString("0", UTF_8)); stream().transportState().transportHeadersReceived(trailers, true); ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class); ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class); verify(listener).closed(captor.capture(), same(PROCESSED), metadataCaptor.capture()); Status status = captor.getValue(); assertEquals(Status.Code.UNKNOWN, status.getCode()); assertTrue(status.getDescription().contains("content-type")); assertEquals("application/bad", metadataCaptor.getValue() .get(Metadata.Key.of("Content-Type", Metadata.ASCII_STRING_MARSHALLER))); }
@Override protected TransportState transportState() { return state; }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); @Override void setAuthority(String authority); @Override Attributes getAttributes(); }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); @Override void setAuthority(String authority); @Override Attributes getAttributes();  }