/** * Create a new {@link ChunkedBody} to encode the contents of the given stream. * <p> * The stream is read lazily, so it shouldn't be closed until this body is consumed. * * @param stream content to encode * @param contentType Content-Type of the stream contents * @param chunkLength the length of each chunk * @param bodyDecoder decoder capable of decoding the body. The last encoding must be "chunked". * @param metadataParser metadata parser (chunked body may contain metadata) * @throws IllegalArgumentException if the bodyDecoder's last encoding is not "chunked" */ public ChunkedBody(InputStream stream, @Nullable String contentType, int chunkLength, BodyDecoder bodyDecoder, HttpMetadataParser metadataParser) { super(contentType, bodyDecoder); this.stream = stream; this.chunkLength = chunkLength; this.metadataParser = metadataParser; validateEncodings(bodyDecoder.getEncodings()); }
/** * Create a new {@link ChunkedBody} to encode the contents of the given stream. * <p> * The stream is read lazily, so it shouldn't be closed until this body is consumed. * * @param stream content to encode * @param contentType Content-Type of the stream contents * @param chunkLength the length of each chunk * @param bodyDecoder decoder capable of decoding the body. The last encoding must be "chunked". * @param metadataParser metadata parser (chunked body may contain metadata) * @throws IllegalArgumentException if the bodyDecoder's last encoding is not "chunked" */ public ChunkedBody(InputStream stream, @Nullable String contentType, int chunkLength, BodyDecoder bodyDecoder, HttpMetadataParser metadataParser) { super(contentType, bodyDecoder); this.stream = stream; this.chunkLength = chunkLength; this.metadataParser = metadataParser; validateEncodings(bodyDecoder.getEncodings()); }