fix(docker): read_response now handles chunked data

This commit is contained in:
Jef Roosens 2022-05-15 00:23:52 +02:00
parent 1811ebbe3f
commit 79fd9c1f87
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 31 additions and 8 deletions

View file

@ -23,6 +23,17 @@ pub fn exit_with_message(code int, msg string) {
exit(code)
}
// reader_to_writer tries to consume the entire reader & write it to the writer.
pub fn reader_to_writer(mut reader io.Reader, mut writer io.Writer) ? {
mut buf := []u8{len: 10 * 1024}
for {
c := reader.read(mut buf) or { break }
writer.write(buf) or { break }
}
}
// reader_to_file writes the contents of a BufferedReader to a file
pub fn reader_to_file(mut reader io.BufferedReader, length int, path string) ? {
mut file := os.create(path)?