GConverterInputStream doesn't pack all data into when calling g_input_stream_read_bytes()
Submitted by Lionel Landwerlin
Link to original bug (#697799)
Description
The documentation specify that g_input_stream_read_bytes() should return the requested amount of data unless it's near to the end of the file/stream. Below is an example we feed 4000 bytes of data to the compressor input stream, and the first amount of data we get is 10bytes (which I believe is a header length or something like that), even though we have enough space to get the whole thing.
============================================
const GLib = imports.gi.GLib; const Gio = imports.gi.Gio;
let str = ''; for (let i = 0; i < 1000; i++) str += 'test' + i;
let input = new Gio.ConverterInputStream({ base_stream: Gio.MemoryInputStream.new_from_data(str), converter: new Gio.ZlibCompressor({ format: Gio.ZlibCompressorFormat.GZIP, }), });
let ret; while ((ret = input.read_bytes(10000000, null)) && ret.get_size() > 0) log('Got ' + ret.get_size() + 'bytes');
Version: 2.36.x