tango.net.http.ChunkStream

License:
BSD style:

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: tango.io.device.Conduit.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

final size_t write(const(void)[] src);
Write a chunk to the output, prefixed and postfixed in a manner consistent with the HTTP chunked transfer coding

final void terminate(scope void delegate(OutputBuffer) headers = null);
Write a zero length chunk, trailing headers and a terminating blank line

class ChunkInput: tango.io.stream.Lines.Lines!(char).Lines;
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);
Reset ChunkInput to a new InputStream

final size_t read(void[] dst);
Read content based on a previously parsed chunk size


Page generated by Ddoc. Copyright (c) Nov 2007 Kris Bell. All rights reserved