Skip to content

Instantly share code, notes, and snippets.

@zestime
Created January 29, 2019 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zestime/2c8ea6137e566b2c6155f0d09b557c24 to your computer and use it in GitHub Desktop.
Save zestime/2c8ea6137e566b2c6155f0d09b557c24 to your computer and use it in GitHub Desktop.
Decoding chunked and gzipped response
var bufferToString = buf => buf.toString('utf-8');
var conv = arr => bufferToString(zlib.gunzipSync(Buffer.from(arr.join(''), 'hex')));
/* testing
var res = [ '1f8b0800000000000213',
'ab562a4b2d2acecccf2b56b25288562a32d033d03354d25100b10cf50ca02c2338cb18c88a05324bf38a4b12937252e3d352134b4a
8b5241daab9572f57212ab2ae373f21353e273537393804603c54b8a4a536b6b01655b8d116a000000' ];
conv(res); // '{"versions": ["r0.0.1", "r0.1.0", "r0.2.0", "r0.3.0"], "unstable_features": {"m.lazy_load_members": true}}'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment