Improve performance of encodeHeader

This commit is contained in:
alain 2013-06-28 15:57:26 -07:00 committed by Norman Maurer
parent 7e3a01cc51
commit 9633769909

View File

@ -125,11 +125,17 @@ public abstract class HttpObjectEncoder<H extends HttpMessage> extends MessageTo
}
private static void encodeHeader(ByteBuf buf, String header, String value) {
buf.writeBytes(header.getBytes(CharsetUtil.US_ASCII));
encodeAscii(header, buf);
buf.writeBytes(HEADER_SEPARATOR);
buf.writeBytes(value.getBytes(CharsetUtil.US_ASCII));
encodeAscii(value, buf);
buf.writeBytes(CRLF);
}
private static void encodeAscii(String s, ByteBuf buf) {
for (int i = 0; i < s.length(); i++) {
buf.writeByte(s.charAt(i));
}
}
protected abstract void encodeInitialLine(ByteBuf buf, H message) throws Exception;
}