[erlang-patches] Handling of http chunked encoding

Bernard Duggan <>
Wed Apr 29 08:36:25 CEST 2009

Hi all,
    We had to make a slight modification to erlang's handling of chunked
encoding to make it work with a system we have here.  The problem is
this:  We're using http chunked encoding to implement a long term
connection where status updates are periodically sent as http chunks. 
My understanding is that this is a bit of an abuse of the system (I
didn't come up with it, I swear :)), but that it's also not an
especially uncommon use.  Each status update is a full chunk with the
size and complete body.  The problem is that the http library won't
forward on a chunk to the client process until the size field for the
following chunk has been received, due to it wanting to check if it's
the last chunk (indicated by the next size field being 0).  The net
effect is that we can't extract a status update chunk until the next one
arrives (which is some indeterminate time away).
    The attached patch makes a small modification to forward any full
chunk received, regardless of whether the size field for the following
chunk has been received yet.  I'm not sure whether or not you'll want to
include it (there may be a very good reason for it working the way it
does, and by my understanding it's not technically breaking any rules as
it currently works), but it doesn't seem to do any harm and gets clients
valid data sooner.
    The patch is against R13B.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: http_chunk_patch.diff
Type: text/x-diff
Size: 1302 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20090429/4a1ede89/attachment.bin>

More information about the erlang-patches mailing list