Change comments and test error message for grpcMessageEncode

This commit is contained in:
Menghan Li
2016-07-19 15:59:54 -07:00
parent 6732fdf9f8
commit 32d3a3587c
2 changed files with 10 additions and 7 deletions

View File

@ -566,8 +566,12 @@ const (
percentByte = '%'
)
// grpcMessageEncode encodes the grpc-message field in the same
// manner as https://github.com/grpc/grpc-java/pull/1517.
// grpcMessageEncode is used to encode status code in header field
// "grpc-message".
// It checks to see if each individual byte in msg is an
// allowable byte, and then either percent encoding or passing it through.
// When percent encoding, the byte is converted into hexadecimal notation
// with a '%' prepended.
func grpcMessageEncode(msg string) string {
if msg == "" {
return ""
@ -596,8 +600,7 @@ func grpcMessageEncodeUnchecked(msg string) string {
return buf.String()
}
// grpcMessageDecode decodes the grpc-message field in the same
// manner as https://github.com/grpc/grpc-java/pull/1517.
// grpcMessageDecode decodes the msg encoded by grpcMessageEncode.
func grpcMessageDecode(msg string) string {
if msg == "" {
return ""

View File

@ -732,7 +732,7 @@ func TestEncodingRequiredStatus(t *testing.T) {
t.Fatalf("Failed to write the request: %v", err)
}
if _, err = ioutil.ReadAll(s); err != nil {
t.Fatal(err)
t.Fatalf("Read got err %v, want <nil>", err)
}
ct.Close()
server.stop()
@ -785,13 +785,13 @@ func TestGrpcMessageDecode(t *testing.T) {
func testGrpcMessageEncode(t *testing.T, input string, expected string) {
actual := grpcMessageEncode(input)
if expected != actual {
t.Errorf("Expected %s from grpcMessageEncode, got %s", expected, actual)
t.Errorf("grpcMessageEncode(%v) = %v, want %v", input, actual, expected)
}
}
func testGrpcMessageDecode(t *testing.T, input string, expected string) {
actual := grpcMessageDecode(input)
if expected != actual {
t.Errorf("Expected %s from grpcMessageDecode, got %s", expected, actual)
t.Errorf("grpcMessageDncode(%v) = %v, want %v", input, actual, expected)
}
}