Skip to content

Commit

Permalink
Allow >16k status desc
Browse files Browse the repository at this point in the history
  • Loading branch information
iamqizhao committed Nov 19, 2015
1 parent f53fd36 commit 900db87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
var (
expectedRequest = "ping"
expectedResponse = "pong"
sizeLargeErr = 1024 * 1024
)

type testCodec struct {
Expand Down Expand Up @@ -91,7 +92,8 @@ func (h *testStreamHandler) handleStream(t *testing.T, s *transport.Stream) {
t.Fatalf("Failed to unmarshal the received message %v", err)
}
if v != expectedRequest {
t.Fatalf("handleStream got %v, want %v", v, expectedRequest)
h.t.WriteStatus(s, codes.Internal, string(make([]byte, sizeLargeErr)))
return
}
}
// send a response back to end the stream.
Expand Down Expand Up @@ -192,5 +194,21 @@ func TestInvoke(t *testing.T) {
if err := Invoke(context.Background(), "/foo/bar", &expectedRequest, &reply, cc); err != nil || reply != expectedResponse {
t.Fatalf("grpc.Invoke(_, _, _, _, _) = %v, want <nil>", err)
}
cc.Close()
server.stop()
}

func TestInvokeLargeErr(t *testing.T) {
server, cc := setUp(t, 0, math.MaxUint32)
var reply string
req := "hello"
err := Invoke(context.Background(), "/foo/bar", &req, &reply, cc)
if _, ok := err.(rpcError); !ok {
t.Fatalf("grpc.Invoke(_, _, _, _, _) receives non rpc error.")
}
if Code(err) != codes.Internal || len(ErrorDesc(err)) != sizeLargeErr {
t.Fatalf("grpc.Invoke(_, _, _, _, _) = %v, want an error of code %d and desc size %d", err, codes.Internal, sizeLargeErr)
}
cc.Close()
server.stop()
}
2 changes: 1 addition & 1 deletion transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ func (t *http2Client) reader() {
endStream := frame.Header().Flags.Has(http2.FlagHeadersEndStream)
curStream = t.operateHeaders(hDec, curStream, frame, endStream)
case *http2.ContinuationFrame:
curStream = t.operateHeaders(hDec, curStream, frame, false)
curStream = t.operateHeaders(hDec, curStream, frame, frame.HeadersEnded())
case *http2.DataFrame:
t.handleData(frame)
case *http2.RSTStreamFrame:
Expand Down

0 comments on commit 900db87

Please sign in to comment.