From 44498e067ff021e144c87d58417c5803f19f9171 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 12 Feb 2009 05:16:38 +0000 Subject: [PATCH] * Improved the detection of chunked encoding * Fixed broken chunk length parser --- .../netty/handler/codec/http/DefaultHttpMessage.java | 11 ++++++++++- .../netty/handler/codec/http/HttpMessageDecoder.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java index 617d091994..33dfcc4cda 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java @@ -91,7 +91,16 @@ public class DefaultHttpMessage implements HttpMessage { public boolean isChunked() { List 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() { diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java index d4efc3f481..5e9b94b99f 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java @@ -224,7 +224,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder= 0) { - hex = hex.substring(delimPos).trim(); + hex = hex.substring(0, delimPos).trim(); } return Integer.parseInt(hex, 16); }