More robust chunk size parser

This commit is contained in:
Trustin Lee 2009-02-12 05:23:39 +00:00
parent 44498e067f
commit 66423e0c1d

View File

@ -222,10 +222,15 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
protected abstract void readInitial(ChannelBuffer buffer) throws Exception;
private int getChunkSize(String hex) {
int delimPos = hex.indexOf(';');
if (delimPos >= 0) {
hex = hex.substring(0, delimPos).trim();
hex = hex.trim();
for (int i = 0; i < hex.length(); i ++) {
char c = hex.charAt(i);
if (c == ';' || Character.isWhitespace(c) || Character.isISOControl(c)) {
hex = hex.substring(0, i);
break;
}
}
return Integer.parseInt(hex, 16);
}