diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java index cd6ccbf3f0..dd7a198bf7 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java @@ -1383,10 +1383,17 @@ public abstract class HttpHeaders implements Iterable> static void encodeAscii0(CharSequence seq, ByteBuf buf) { int length = seq.length(); for (int i = 0 ; i < length; i++) { - buf.writeByte((byte) seq.charAt(i)); + buf.writeByte(c2b(seq.charAt(i))); } } + private static byte c2b(char c) { + if (c > 255) { + return '?'; + } + return (byte) c; + } + /** * Create a new {@link CharSequence} which is optimized for reuse as {@link HttpHeaders} name or value. * So if you have a Header name or value that you want to reuse you should make use of this.