TestClientDecodeHeader validates the handling of initial header frames that do not signal the end of a stream. For all headers that indicate grpc content type, http status will be ignored.
(t *testing.T)
| 2798 | // do not signal the end of a stream. For all headers that indicate grpc content |
| 2799 | // type, http status will be ignored. |
| 2800 | func (s) TestClientDecodeHeader(t *testing.T) { |
| 2801 | tests := []struct { |
| 2802 | name string |
| 2803 | metaHeaderFrame *http2.MetaHeadersFrame |
| 2804 | wantStatus *status.Status |
| 2805 | isNonGRPCStatus bool |
| 2806 | }{ |
| 2807 | { |
| 2808 | name: "valid_header", |
| 2809 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2810 | Fields: []hpack.HeaderField{ |
| 2811 | {Name: "content-type", Value: "application/grpc"}, |
| 2812 | {Name: ":status", Value: "200"}, |
| 2813 | }, |
| 2814 | }, |
| 2815 | wantStatus: status.New(codes.OK, ""), |
| 2816 | }, |
| 2817 | { |
| 2818 | name: "missing_content_type_header", |
| 2819 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2820 | Fields: []hpack.HeaderField{ |
| 2821 | {Name: "grpc-status", Value: "0"}, |
| 2822 | {Name: ":status", Value: "200"}, |
| 2823 | }, |
| 2824 | }, |
| 2825 | wantStatus: status.New( |
| 2826 | codes.Unknown, |
| 2827 | "unexpected HTTP status code received from server: 200 (OK); malformed header: missing HTTP content-type", |
| 2828 | ), |
| 2829 | isNonGRPCStatus: true, |
| 2830 | }, |
| 2831 | { |
| 2832 | name: "invalid_grpc_status", |
| 2833 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2834 | Fields: []hpack.HeaderField{ |
| 2835 | {Name: "content-type", Value: "application/grpc"}, |
| 2836 | {Name: "grpc-status", Value: "xxxx"}, |
| 2837 | {Name: ":status", Value: "200"}, |
| 2838 | }, |
| 2839 | }, |
| 2840 | wantStatus: status.New( |
| 2841 | codes.Unknown, |
| 2842 | "transport: malformed grpc-status: strconv.ParseInt: parsing \"xxxx\": invalid syntax", |
| 2843 | ), |
| 2844 | }, |
| 2845 | { |
| 2846 | name: "invalid_content_type", |
| 2847 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2848 | Fields: []hpack.HeaderField{ |
| 2849 | {Name: "content-type", Value: "application/json"}, |
| 2850 | }, |
| 2851 | }, |
| 2852 | wantStatus: status.New( |
| 2853 | codes.Internal, |
| 2854 | "malformed header: missing HTTP status; transport: received unexpected content-type \"application/json\"", |
| 2855 | ), |
| 2856 | isNonGRPCStatus: true, |
| 2857 | }, |
nothing calls this directly
no test coverage detected