You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Matteo Merli <ma...@gmail.com> on 2007/12/17 18:12:01 UTC

Problem with http chucked body decoder

Hi,

I've found a problem in the HTTP codec because some server incorrectly
send the chunk length.

These servers send the length follwed by some spaces, before the CRLF
terminator.

Example: http://del.icio.us/

The following patch fixed the problem for me:

Index: filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
===================================================================
--- filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
    (revision 604818)
+++ filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
    (working copy)
@@ -107,8 +107,8 @@
         protected boolean isTerminator(byte b) {
             if (!(b >= '0' && b <= '9' || b >= 'a' && b <= 'f' || b >= 'A'
                     && b <= 'F')) {
-                if (b == '\r' || b == ';') {
-                    chunkHasExtension = b == ';';
+                if (b == ' ' || b == '\r' || b == ';') {
+                    chunkHasExtension = (b == ';' || b == ' ');
                     return true;
                 }
                 throw new IllegalArgumentException();


Best regards,
Matteo

-- 
Matteo Merli
<ma...@gmail.com>

Re: Problem with http chucked body decoder

Posted by Trustin Lee <tr...@gmail.com>.
Hi Matteo,

Thanks for the patch!  I've just applied it to trunk.

HTH,
Trustin

On Dec 18, 2007 2:12 AM, Matteo Merli <ma...@gmail.com> wrote:
> Hi,
>
> I've found a problem in the HTTP codec because some server incorrectly
> send the chunk length.
>
> These servers send the length follwed by some spaces, before the CRLF
> terminator.
>
> Example: http://del.icio.us/
>
> The following patch fixed the problem for me:
>
> Index: filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
> ===================================================================
> --- filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
>     (revision 604818)
> +++ filter-codec-http/src/main/java/org/apache/mina/filter/codec/http/ChunkedBodyDecodingState.java
>     (working copy)
> @@ -107,8 +107,8 @@
>          protected boolean isTerminator(byte b) {
>              if (!(b >= '0' && b <= '9' || b >= 'a' && b <= 'f' || b >= 'A'
>                      && b <= 'F')) {
> -                if (b == '\r' || b == ';') {
> -                    chunkHasExtension = b == ';';
> +                if (b == ' ' || b == '\r' || b == ';') {
> +                    chunkHasExtension = (b == ';' || b == ' ');
>                      return true;
>                  }
>                  throw new IllegalArgumentException();
>
>
> Best regards,
> Matteo
>
> --
> Matteo Merli
> <ma...@gmail.com>
>



-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6