Line data Source code
1 : // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 : // for details. All rights reserved. Use of this source code is governed by a 3 : // BSD-style license that can be found in the LICENSE file. 4 : 5 : import 'dart:convert'; 6 : 7 : import 'chunked_coding/decoder.dart'; 8 : import 'chunked_coding/encoder.dart'; 9 : 10 : export 'chunked_coding/decoder.dart' hide chunkedCodingDecoder; 11 : export 'chunked_coding/encoder.dart' hide chunkedCodingEncoder; 12 : 13 : /// The canonical instance of [ChunkedCodingCodec]. 14 : const chunkedCoding = ChunkedCodingCodec._(); 15 : 16 : /// A codec that encodes and decodes the [chunked transfer coding][]. 17 : /// 18 : /// [chunked transfer coding]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1 19 : /// 20 : /// The [encoder] creates a *single* chunked message for each call to 21 : /// [ChunkedCodingEncoder.convert] or 22 : /// [ChunkedCodingEncoder.startChunkedConversion]. This means that it will 23 : /// always add an end-of-message footer once conversion has finished. It doesn't 24 : /// support generating chunk extensions or trailing headers. 25 : /// 26 : /// Similarly, the [decoder] decodes a *single* chunked message into a stream of 27 : /// byte arrays that must be concatenated to get the full list (like most Dart 28 : /// byte streams). It doesn't support decoding a stream that contains multiple 29 : /// chunked messages, nor does it support a stream that contains chunked data 30 : /// mixed with other types of data. 31 : /// 32 : /// Currently, [decoder] will fail to parse chunk extensions and trailing 33 : /// headers. It may be updated to silently ignore them in the future. 34 : class ChunkedCodingCodec extends Codec<List<int>, List<int>> { 35 0 : @override 36 : ChunkedCodingEncoder get encoder => chunkedCodingEncoder; 37 : 38 0 : @override 39 : ChunkedCodingDecoder get decoder => chunkedCodingDecoder; 40 : 41 11 : const ChunkedCodingCodec._(); 42 : }