#1854 "sys::IOErr: Invalid format for HTTP chunked transfer" while parsing HTTP reposone

dluksza Sat 24 Mar 2012

I've discovered this issue while implementing simple web bot. My quick investigation shows that in some cases line variable in ChunkInStream#checkChunk cannot be converted because it contains white pace. Therefore parse exception is thrown, unfortunately root exception is hidden and only enigmatic Invalid format for HTTP chunked transfer encoding information is shown.

Simple trim call before toInt fixes this issue.

Here is simple patch that I've created:

diff -r 70c9eca05135 src/web/fan/WebUtil.fan
--- a/src/web/fan/WebUtil.fan	Fri Mar 23 14:33:10 2012 -0400
+++ b/src/web/fan/WebUtil.fan	Sat Mar 24 00:51:07 2012 +0100
@@ -452,7 +452,7 @@
       line := in.readLine
       semi := line.index(";")
       if (semi != null) line = line[0..semi]
  • chunkRem = line.toInt(16) + chunkRem = line.trim.toInt(16)
    // if we have more chunks keep chugging
    if (chunkRem > 0) return true

brian Sat 24 Mar 2012

Thanks, pushed your fix - changeset

BTW, do you know what web server was adding spaces?

dluksza Sat 24 Mar 2012

Thanks for quick resposne!

Web server introduces it self as "Apache" but sice it is an finansial institution I won't be 100% sure if this is true.

Login or Signup to reply.