* Improved the detection of chunked encoding

* Fixed broken chunk length parser
This commit is contained in:
Trustin Lee 2009-02-12 05:16:38 +00:00
parent 01b0beab50
commit 44498e067f
2 changed files with 11 additions and 2 deletions

View File

@ -91,7 +91,16 @@ public class DefaultHttpMessage implements HttpMessage {
public boolean isChunked() {
List<String> chunked = headers.get(HttpHeaders.Names.TRANSFER_ENCODING);
return chunked != null && chunked.size() > 0 && chunked.get(0).equalsIgnoreCase(HttpHeaders.Values.CHUNKED);
if (chunked == null || chunked.isEmpty()) {
return false;
}
for (String v: chunked) {
if (v.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) {
return true;
}
}
return false;
}
public void clearHeaders() {

View File

@ -224,7 +224,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
private int getChunkSize(String hex) {
int delimPos = hex.indexOf(';');
if (delimPos >= 0) {
hex = hex.substring(delimPos).trim();
hex = hex.substring(0, delimPos).trim();
}
return Integer.parseInt(hex, 16);
}