TestClientDecodeTrailer validates the handling of trailer frames, which may or may not also be the initial header frame (header-only response).
(t *testing.T)
| 2941 | // TestClientDecodeTrailer validates the handling of trailer frames, which may |
| 2942 | // or may not also be the initial header frame (header-only response). |
| 2943 | func (s) TestClientDecodeTrailer(t *testing.T) { |
| 2944 | tests := []struct { |
| 2945 | name string |
| 2946 | metaHeaderFrame *http2.MetaHeadersFrame |
| 2947 | wantEndStreamStatus *status.Status |
| 2948 | }{ |
| 2949 | { |
| 2950 | name: "valid_trailer", |
| 2951 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2952 | Fields: []hpack.HeaderField{ |
| 2953 | {Name: "content-type", Value: "application/grpc"}, |
| 2954 | {Name: "grpc-status", Value: "0"}, |
| 2955 | {Name: ":status", Value: "200"}, |
| 2956 | }, |
| 2957 | }, |
| 2958 | wantEndStreamStatus: status.New(codes.OK, ""), |
| 2959 | }, |
| 2960 | { |
| 2961 | name: "missing_content_type_in_grpc_mode", |
| 2962 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2963 | Fields: []hpack.HeaderField{ |
| 2964 | {Name: "grpc-status", Value: "0"}, |
| 2965 | {Name: ":status", Value: "200"}, |
| 2966 | }, |
| 2967 | }, |
| 2968 | wantEndStreamStatus: status.New(codes.OK, ""), |
| 2969 | }, |
| 2970 | { |
| 2971 | name: "invalid_grpc_status", |
| 2972 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2973 | Fields: []hpack.HeaderField{ |
| 2974 | {Name: "content-type", Value: "application/grpc"}, |
| 2975 | {Name: "grpc-status", Value: "xxxx"}, |
| 2976 | {Name: ":status", Value: "200"}, |
| 2977 | }, |
| 2978 | }, |
| 2979 | wantEndStreamStatus: status.New( |
| 2980 | codes.Unknown, |
| 2981 | "transport: malformed grpc-status: strconv.ParseInt: parsing \"xxxx\": invalid syntax", |
| 2982 | ), |
| 2983 | }, |
| 2984 | { |
| 2985 | name: "missing_grpc_status_in_grpc_mode", |
| 2986 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2987 | Fields: []hpack.HeaderField{ |
| 2988 | {Name: ":status", Value: "xxxx"}, |
| 2989 | }, |
| 2990 | }, |
| 2991 | wantEndStreamStatus: status.New(codes.Unknown, ""), |
| 2992 | }, |
| 2993 | { |
| 2994 | name: "http2_frame_size_exceeds", |
| 2995 | metaHeaderFrame: &http2.MetaHeadersFrame{ |
| 2996 | Truncated: true, |
| 2997 | }, |
| 2998 | wantEndStreamStatus: status.New( |
| 2999 | codes.Internal, |
| 3000 | "peer header list size exceeded limit", |
nothing calls this directly
no test coverage detected