tango.net.http.ChunkStream

License:

BSD style: see license.txt

Version:

Nov 2007: Initial release

Author:

Kris

Support for HTTP chunked I/O.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
class ChunkOutput : OutputFilter
Prefix each block of data with its length (in hex digits) and add appropriate \r\n sequences. To commit the stream you'll need to use the terminate() function and optionally provide it with a callback for writing trailing headers
this(OutputStream stream)
Use a buffer belonging to our sibling, if one is available
size_t write(const(void)[] src) [override, final]
Write a chunk to the output, prefixed and postfixed in a manner consistent with the HTTP chunked transfer coding
void terminate(scope void delegate(OutputBuffer) headers = null) [final]
Write a zero length chunk, trailing headers and a terminating blank line
class ChunkInput : Lines!(char)
Parse hex digits, and use the resultant size to modulate requests for incoming data. A chunk size of 0 terminates the stream, so to read any trailing headers you'll need to provide a delegate handler for receiving those
this(InputStream stream, Headers headers = null)
Prime the available chunk size by reading and parsing the first available line
ChunkInput set(InputStream stream) [override]
Reset ChunkInput to a new InputStream
size_t read(void[] dst) [override, final]
Read content based on a previously parsed chunk size