Class GrpcDerivedHeaders

java.lang.Object
org.mockserver.grpc.GrpcDerivedHeaders

public class GrpcDerivedHeaders extends Object
The x-grpc-* request headers MockServer derives itself from the gRPC request (the :path and the decoded frame), as opposed to metadata the client sent.

Why this exists. HttpRequest.withHeader appends rather than replaces, so a client that sends its own x-grpc-service: evil leaves the converted request carrying both values — [evil, com.example.GreetingService]. Header matching is SUB_SET, so an expectation qualified by the spoofed service name would then match a stream that belongs to a different service. Routing itself is driven by the real :path, so the impact is on matching integrity rather than dispatch, but these headers are documented as server-derived and must actually be.

strip(HttpRequest) is therefore called immediately before the derived values are set, on every transport — HTTP/1.1 and HTTP/2 (GrpcToHttpRequestHandler), HTTP/2 bidi (GrpcBidiRouterHandler) and HTTP/3 (GrpcHttp3Adapter, Http3MockServerHandler).