I had to create a SignalR client because I wanted to try Bittrex websockets API, everything went great until I receive responses from the API (Subscription data, simple calls, etc...) they state in the docs:
\n\n\n\n\nAll responses are compressed by the server using GZip (via a \xe2\x80\x98deflate\xe2\x80\x99 API - there are no headers) and base64 encoded prior to transmission. Users must reverse this process to retrieve the JSON payload.
\n
I\'ve tried using :zlib.(gunzip, gzip, uncompress)
just for the sake of it and they always return an error, obviously after decoding it with Base.decode64()
. Example:
string = "jZC7DsIwDEX/xXOIEjuJ44w8tgKChgFQV36i6r+TvpAqQOAlUnR87OsW9pDgUm/zap03oOAAydrggoIbpHsL+Vo+FJwhiWWvnYyl4ATJaNOpEcEJCVGbqSYEQ4jMxDM5y5C18QvyJTMDEp2QtoiLeUguipcPpCEyTEIzGZiILXWNgrokKc9jCHTMJXC9qyr4srLVxJFLexlaWOvRcbSOXWTq5/4UDGsiY3/EvwQf7ipMTnrfm6Dpng=="\n\nstring |> Base.decode64!() |> :zlib.gunzip()\n\n# This returns a :data_error from `:zlib`\n\nBase.decode64!(string) \n\n<<141, 144, 187, 14, 194, 48, 12, 69, 255, 197, 115, 136, 18, 59, 137, 227, 140,\n 60, 182, 2, 130, 134, 1, 80, 87, 126, 162, 234, 191, 147, 190, 144, 42, 64,\n 224, 37, 82, 116, 124, 236, 235, 22, 246, 144, 224, 82, 111, 243, 106, 157,\n ...>>\n
Run Code Online (Sandbox Code Playgroud)\n\n另一方面,它已使用 Base 成功解码,并且我得到了一个二进制文件,我不确定如何将其转换为字符串,但由于文档声明它已被压缩,并且我认为有必要解压缩数据。我尝试使用其他方法将二进制文件转换为字符串,但没有结果。
\n