mirror of https://github.com/grpc/grpc-java.git
netty: server support extension content types (#2306)
Removed a (left over?) content type check that checks for equality with "application/grpc". The content type is verified using checkContentType(..).
This commit is contained in:
parent
28ba5995de
commit
7aa0e1a901
|
|
@ -33,7 +33,6 @@ package io.grpc.netty;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.grpc.netty.Utils.CONTENT_TYPE_GRPC;
|
||||
import static io.grpc.netty.Utils.CONTENT_TYPE_HEADER;
|
||||
import static io.grpc.netty.Utils.HTTP_METHOD;
|
||||
import static io.grpc.netty.Utils.TE_HEADER;
|
||||
|
|
@ -420,7 +419,6 @@ class NettyServerHandler extends AbstractNettyHandler {
|
|||
throw Http2Exception.streamError(streamId, Http2Error.REFUSED_STREAM,
|
||||
"Method '%s' is not supported", headers.method());
|
||||
}
|
||||
checkHeader(streamId, headers, CONTENT_TYPE_HEADER, CONTENT_TYPE_GRPC);
|
||||
// Remove the leading slash of the path and get the fully qualified method name
|
||||
CharSequence path = headers.path();
|
||||
if (path.charAt(0) != '/') {
|
||||
|
|
|
|||
|
|
@ -298,6 +298,24 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
|
|||
any(ChannelPromise.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersSupportExtensionContentType() throws Exception {
|
||||
Http2Headers headers = new DefaultHttp2Headers()
|
||||
.method(HTTP_METHOD)
|
||||
.set(CONTENT_TYPE_HEADER, new AsciiString("application/grpc+json", UTF_8))
|
||||
.set(TE_HEADER, TE_TRAILERS)
|
||||
.path(new AsciiString("/foo/bar"));
|
||||
ByteBuf headersFrame = headersFrame(STREAM_ID, headers);
|
||||
channelRead(headersFrame);
|
||||
|
||||
ArgumentCaptor<NettyServerStream> streamCaptor =
|
||||
ArgumentCaptor.forClass(NettyServerStream.class);
|
||||
ArgumentCaptor<String> methodCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(transportListener).streamCreated(streamCaptor.capture(), methodCaptor.capture(),
|
||||
any(Metadata.class));
|
||||
stream = streamCaptor.getValue();
|
||||
}
|
||||
|
||||
private void createStream() throws Exception {
|
||||
Http2Headers headers = new DefaultHttp2Headers()
|
||||
.method(HTTP_METHOD)
|
||||
|
|
|
|||
Loading…
Reference in New Issue