netty: Use charset=utf-8, not encoding=utf-8 for error pages

This has been wrong since the introduction of the code in df357cb8.
Noticed as part of https://github.com/grpc/grpc-go/pull/4491 . The error
text is generally ASCII, so this probably doesn't matter much.
This commit is contained in:
Eric Anderson 2021-07-19 13:32:11 -07:00 committed by GitHub
parent b9becb5c8e
commit a282019902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -764,7 +764,7 @@ class NettyServerHandler extends AbstractNettyHandler {
Http2Headers headers = new DefaultHttp2Headers(true, serialized.length / 2) Http2Headers headers = new DefaultHttp2Headers(true, serialized.length / 2)
.status("" + code) .status("" + code)
.set(CONTENT_TYPE_HEADER, "text/plain; encoding=utf-8"); .set(CONTENT_TYPE_HEADER, "text/plain; charset=utf-8");
for (int i = 0; i < serialized.length; i += 2) { for (int i = 0; i < serialized.length; i += 2) {
headers.add(new AsciiString(serialized[i], false), new AsciiString(serialized[i + 1], false)); headers.add(new AsciiString(serialized[i], false), new AsciiString(serialized[i + 1], false));
} }

View File

@ -432,7 +432,7 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
.set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.INTERNAL.value())) .set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.INTERNAL.value()))
.set(InternalStatus.MESSAGE_KEY.name(), "Content-Type 'application/bad' is not supported") .set(InternalStatus.MESSAGE_KEY.name(), "Content-Type 'application/bad' is not supported")
.status("" + 415) .status("" + 415)
.set(CONTENT_TYPE_HEADER, "text/plain; encoding=utf-8"); .set(CONTENT_TYPE_HEADER, "text/plain; charset=utf-8");
verifyWrite() verifyWrite()
.writeHeaders( .writeHeaders(
@ -457,7 +457,7 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
.set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.INTERNAL.value())) .set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.INTERNAL.value()))
.set(InternalStatus.MESSAGE_KEY.name(), "Method 'FAKE' is not supported") .set(InternalStatus.MESSAGE_KEY.name(), "Method 'FAKE' is not supported")
.status("" + 405) .status("" + 405)
.set(CONTENT_TYPE_HEADER, "text/plain; encoding=utf-8"); .set(CONTENT_TYPE_HEADER, "text/plain; charset=utf-8");
verifyWrite() verifyWrite()
.writeHeaders( .writeHeaders(
@ -481,7 +481,7 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
.set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.UNIMPLEMENTED.value())) .set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.UNIMPLEMENTED.value()))
.set(InternalStatus.MESSAGE_KEY.name(), "Expected path but is missing") .set(InternalStatus.MESSAGE_KEY.name(), "Expected path but is missing")
.status("" + 404) .status("" + 404)
.set(CONTENT_TYPE_HEADER, "text/plain; encoding=utf-8"); .set(CONTENT_TYPE_HEADER, "text/plain; charset=utf-8");
verifyWrite() verifyWrite()
.writeHeaders( .writeHeaders(
@ -506,7 +506,7 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
.set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.UNIMPLEMENTED.value())) .set(InternalStatus.CODE_KEY.name(), String.valueOf(Code.UNIMPLEMENTED.value()))
.set(InternalStatus.MESSAGE_KEY.name(), "Expected path to start with /: foo/bar") .set(InternalStatus.MESSAGE_KEY.name(), "Expected path to start with /: foo/bar")
.status("" + 404) .status("" + 404)
.set(CONTENT_TYPE_HEADER, "text/plain; encoding=utf-8"); .set(CONTENT_TYPE_HEADER, "text/plain; charset=utf-8");
verifyWrite() verifyWrite()
.writeHeaders( .writeHeaders(