Change comments and test error message for grpcMessageEncode
This commit is contained in:
@ -566,8 +566,12 @@ const (
|
|||||||
percentByte = '%'
|
percentByte = '%'
|
||||||
)
|
)
|
||||||
|
|
||||||
// grpcMessageEncode encodes the grpc-message field in the same
|
// grpcMessageEncode is used to encode status code in header field
|
||||||
// manner as https://github.com/grpc/grpc-java/pull/1517.
|
// "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 {
|
func grpcMessageEncode(msg string) string {
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
return ""
|
return ""
|
||||||
@ -596,8 +600,7 @@ func grpcMessageEncodeUnchecked(msg string) string {
|
|||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// grpcMessageDecode decodes the grpc-message field in the same
|
// grpcMessageDecode decodes the msg encoded by grpcMessageEncode.
|
||||||
// manner as https://github.com/grpc/grpc-java/pull/1517.
|
|
||||||
func grpcMessageDecode(msg string) string {
|
func grpcMessageDecode(msg string) string {
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
return ""
|
return ""
|
||||||
|
@ -732,7 +732,7 @@ func TestEncodingRequiredStatus(t *testing.T) {
|
|||||||
t.Fatalf("Failed to write the request: %v", err)
|
t.Fatalf("Failed to write the request: %v", err)
|
||||||
}
|
}
|
||||||
if _, err = ioutil.ReadAll(s); err != nil {
|
if _, err = ioutil.ReadAll(s); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatalf("Read got err %v, want <nil>", err)
|
||||||
}
|
}
|
||||||
ct.Close()
|
ct.Close()
|
||||||
server.stop()
|
server.stop()
|
||||||
@ -785,13 +785,13 @@ func TestGrpcMessageDecode(t *testing.T) {
|
|||||||
func testGrpcMessageEncode(t *testing.T, input string, expected string) {
|
func testGrpcMessageEncode(t *testing.T, input string, expected string) {
|
||||||
actual := grpcMessageEncode(input)
|
actual := grpcMessageEncode(input)
|
||||||
if expected != actual {
|
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) {
|
func testGrpcMessageDecode(t *testing.T, input string, expected string) {
|
||||||
actual := grpcMessageDecode(input)
|
actual := grpcMessageDecode(input)
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
t.Errorf("Expected %s from grpcMessageDecode, got %s", expected, actual)
|
t.Errorf("grpcMessageDncode(%v) = %v, want %v", input, actual, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user