@@ -1511,31 +1511,29 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
1511
1511
}
1512
1512
}
1513
1513
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 .
1516
1516
// 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.
1518
1518
if ! isGRPC {
1519
1519
var grpcErrorCode = codes .Internal
1520
- switch httpStatus {
1521
- case "" :
1520
+ if httpStatus == "" {
1522
1521
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 )
1526
1525
if err != nil {
1527
1526
se := status .New (grpcErrorCode , fmt .Sprintf ("transport: malformed http-status: %v" , err ))
1528
1527
t .closeStream (s , se .Err (), true , http2 .ErrCodeProtocol , se , nil , endStream )
1529
1528
return
1530
1529
}
1531
- statusCode := int (c )
1532
1530
if statusCode >= 100 && statusCode < 200 {
1533
1531
if endStream {
1534
1532
se := status .New (codes .Internal , fmt .Sprintf (
1535
1533
"protocol error: informational header with status code %d must not have END_STREAM set" , statusCode ))
1536
1534
t .closeStream (s , se .Err (), true , http2 .ErrCodeProtocol , se , nil , endStream )
1537
1535
}
1538
- // In case of informational headers return
1536
+ // In case of informational headers, return.
1539
1537
return
1540
1538
}
1541
1539
httpStatusErr = fmt .Sprintf (
0 commit comments