| Did you know ... | Search Documentation: |
| Predicate http_chunked_open/3 |
true (default false), the parent stream is closed
if DataStream is closed.set_stream(DataStream, buffer(line)) on the data stream to
get line-buffered output. See set_stream/2 for details.
Switching buffering to false is supported.Here is example code to write a chunked data to a stream
http_chunked_open(Out, S, []),
format(S, 'Hello world~n', []),
close(S).
If a stream is known to contain chunked data, we can extract this data using
http_chunked_open(In, S, []),
read_stream_to_codes(S, Codes),
close(S).
The chunked protocol allows for two types of out of band data. Each chunk may be associated with additional metadata. That is achieved using http_chunked_flush/2. The last chunk may be followed by HTTP header lines. That can be achieved by calling http_chunked_add_trailer/3 before closing the chunked stream.
After http_chunked_open/3, the encoding of DataStream is the same as
the encoding of RawStream, while the encoding of RawStream is
octet, the only value allowed for HTTP chunked streams. Closing
the DataStream restores the old encoding on RawStream.
io_error(read, Stream) where the message context provides
an indication of the problem. This error is raised if
the input is not valid HTTP chunked data.