-
Notifications
You must be signed in to change notification settings - Fork 4.6k
client: ignore http status header for gRPC streams #8548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
50b5337
b1a7265
b4cce55
7087664
aceb8be
734cd4d
bebc8d3
09cf708
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2618,6 +2618,8 @@ func (s) TestClientDecodeHeaderStatusErr(t *testing.T) { | |
metaHeaderFrame *http2.MetaHeadersFrame | ||
// output | ||
wantStatus *status.Status | ||
// end stream output | ||
|
||
wantStatusEndStream *status.Status | ||
}{ | ||
{ | ||
name: "valid header", | ||
|
@@ -2695,34 +2697,55 @@ func (s) TestClientDecodeHeaderStatusErr(t *testing.T) { | |
), | ||
}, | ||
{ | ||
name: "bad status in grpc mode", | ||
name: "ignoring bad http status in grpc mode", | ||
metaHeaderFrame: &http2.MetaHeadersFrame{ | ||
Fields: []hpack.HeaderField{ | ||
{Name: "content-type", Value: "application/grpc"}, | ||
{Name: "grpc-status", Value: "0"}, | ||
{Name: ":status", Value: "504"}, | ||
}, | ||
}, | ||
wantStatus: status.New( | ||
codes.Unavailable, | ||
"unexpected HTTP status code received from server: 504 (Gateway Timeout)", | ||
), | ||
wantStatus: status.New(codes.OK, ""), | ||
}, | ||
{ | ||
name: "missing http status", | ||
name: "missing http status and grpc status", | ||
metaHeaderFrame: &http2.MetaHeadersFrame{ | ||
Fields: []hpack.HeaderField{ | ||
{Name: "content-type", Value: "application/grpc"}, | ||
}, | ||
}, | ||
wantStatus: status.New( | ||
codes.Internal, | ||
"malformed header: missing HTTP status", | ||
), | ||
wantStatus: status.New(codes.OK, ""), | ||
wantStatusEndStream: status.New(codes.Internal, ""), | ||
}, | ||
{ | ||
name: "ignore http status and fail for grpc status missing in trailer", | ||
metaHeaderFrame: &http2.MetaHeadersFrame{ | ||
Fields: []hpack.HeaderField{ | ||
{Name: "content-type", Value: "application/grpc"}, | ||
{Name: ":status", Value: "504"}, | ||
}, | ||
}, | ||
wantStatus: status.New(codes.OK, ""), | ||
wantStatusEndStream: status.New(codes.Internal, ""), | ||
}, | ||
{ | ||
name: "trailer only grpc timeout ignores http status", | ||
metaHeaderFrame: &http2.MetaHeadersFrame{ | ||
Fields: []hpack.HeaderField{ | ||
{Name: "content-type", Value: "application/grpc"}, | ||
{Name: "grpc-status", Value: "4"}, | ||
{Name: "grpc-message", Value: "Request timed out: Internal error"}, | ||
{Name: ":status", Value: "200"}, | ||
}, | ||
}, | ||
wantStatusEndStream: status.New(codes.DeadlineExceeded, "Request timed out: Internal error"), | ||
}, | ||
} { | ||
|
||
t.Run(test.name, func(t *testing.T) { | ||
if test.wantStatus == nil { | ||
t.Skip() | ||
} | ||
arjan-bal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
ts := testStream() | ||
s := testClient(ts) | ||
|
||
|
@@ -2733,7 +2756,6 @@ func (s) TestClientDecodeHeaderStatusErr(t *testing.T) { | |
} | ||
|
||
s.operateHeaders(test.metaHeaderFrame) | ||
|
||
got := ts.status | ||
want := test.wantStatus | ||
if got.Code() != want.Code() || got.Message() != want.Message() { | ||
|
@@ -2755,6 +2777,9 @@ func (s) TestClientDecodeHeaderStatusErr(t *testing.T) { | |
|
||
got := ts.status | ||
want := test.wantStatus | ||
if test.wantStatusEndStream != nil { | ||
want = test.wantStatusEndStream | ||
} | ||
arjan-bal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if got.Code() != want.Code() || got.Message() != want.Message() { | ||
t.Fatalf("operateHeaders(%v); status = \ngot: %s\nwant: %s", test.metaHeaderFrame, got, want) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.