Skip to content

Commit bebc8d3

Browse files
committed
splitting the test for headers and trailers
1 parent 734cd4d commit bebc8d3

File tree

2 files changed

+143
-138
lines changed

2 files changed

+143
-138
lines changed

internal/transport/http2_client.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,31 +1511,29 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
15111511
}
15121512
}
15131513

1514-
// If a non gRPC response is received, then evaluate entire http status and
1515-
// process close stream / response.
1514+
// If a non-gRPC response is received, then evaluate the HTTP status to
1515+
// process the response and close the stream.
15161516
// In case http status doesn't provide any error information (status : 200),
1517-
// evalute response code to be Unknown.
1517+
// then evalute response code to be Unknown.
15181518
if !isGRPC {
15191519
var grpcErrorCode = codes.Internal
1520-
switch httpStatus {
1521-
case "":
1520+
if httpStatus == "" {
15221521
httpStatusErr = "malformed header: missing HTTP status"
1523-
default:
1524-
// Any other status code (e.g., "404", "503"). We must parse it.
1525-
c, err := strconv.ParseInt(httpStatus, 10, 32)
1522+
} else {
1523+
// Parse the status codes (e.g. "200", 404").
1524+
statusCode, err := strconv.Atoi(httpStatus)
15261525
if err != nil {
15271526
se := status.New(grpcErrorCode, fmt.Sprintf("transport: malformed http-status: %v", err))
15281527
t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream)
15291528
return
15301529
}
1531-
statusCode := int(c)
15321530
if statusCode >= 100 && statusCode < 200 {
15331531
if endStream {
15341532
se := status.New(codes.Internal, fmt.Sprintf(
15351533
"protocol error: informational header with status code %d must not have END_STREAM set", statusCode))
15361534
t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream)
15371535
}
1538-
// In case of informational headers return
1536+
// In case of informational headers, return.
15391537
return
15401538
}
15411539
httpStatusErr = fmt.Sprintf(

0 commit comments

Comments
 (0)