MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / TestOutgoingTrailerMatcher

Function TestOutgoingTrailerMatcher

runtime/handler_test.go:542–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

540}
541
542func TestOutgoingTrailerMatcher(t *testing.T) {
543 t.Parallel()
544 msg := &pb.SimpleMessage{Id: "foo"}
545 for _, tc := range []struct {
546 name string
547 md runtime.ServerMetadata
548 caller http.Header
549 headers http.Header
550 trailer http.Header
551 matcher runtime.HeaderMatcherFunc
552 }{
553 {
554 name: "default matcher, caller accepts",
555 md: runtime.ServerMetadata{
556 TrailerMD: metadata.Pairs(
557 "foo", "bar",
558 "baz", "qux",
559 ),
560 },
561 caller: http.Header{
562 "Te": []string{"trailers"},
563 },
564 headers: http.Header{
565 "Transfer-Encoding": []string{"chunked"},
566 "Content-Type": []string{"application/json"},
567 "Trailer": []string{"Grpc-Trailer-Baz", "Grpc-Trailer-Foo"},
568 },
569 trailer: http.Header{
570 "Grpc-Trailer-Foo": []string{"bar"},
571 "Grpc-Trailer-Baz": []string{"qux"},
572 },
573 },
574 {
575 name: "default matcher, caller rejects",
576 md: runtime.ServerMetadata{
577 TrailerMD: metadata.Pairs(
578 "foo", "bar",
579 "baz", "qux",
580 ),
581 },
582 headers: http.Header{
583 "Content-Length": []string{"12"},
584 "Content-Type": []string{"application/json"},
585 },
586 },
587 {
588 name: "custom matcher",
589 md: runtime.ServerMetadata{
590 TrailerMD: metadata.Pairs(
591 "foo", "bar",
592 "baz", "qux",
593 ),
594 },
595 caller: http.Header{
596 "Te": []string{"trailers"},
597 },
598 headers: http.Header{
599 "Transfer-Encoding": []string{"chunked"},

Callers

nothing calls this directly

Calls 5

NewServerMetadataContextFunction · 0.92
NewServeMuxFunction · 0.92
WithWriteContentLengthFunction · 0.92
ForwardResponseMessageFunction · 0.92

Tested by

no test coverage detected