nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.84k stars 304 forks source link

Binary data / strings being truncated #78

Closed b1c9g76 closed 10 years ago

b1c9g76 commented 11 years ago

Redis client vs webdis in chrome

redis 127.0.0.1:6379> get test "\x05\bq\b\x14\x15\x18\x02?\x00=\x0c\x00\x00\x00\x00SPGq\b\x14\x15\x1a\x00\x06\n\x06AP\"\x01\xfa\x00\x82\x00\xa0\x00\xb4\x00\xa0\x00\xf4\x01\x9c\x04\x01\x00\x01\x00&\x8c\n\x00\x00\x06p\x17\x00\x00\x02p0\x00\x00\x03t@\x00\x00\x05\xb4F\x00\x00\x01\xa0\xd7\x00\x00"

http://192.168.1.3:7379/GET/test

{"GET":"\u0005\bq\b\u0014\u0015\u0018\u0002?"}

nicolasff commented 11 years ago

Hi,

Unfortunately json doesn't support binary data; the representation in redis-cli is escaped. You can call the URL with a ".bin" suffix to get the raw data.

Cheers, Nicolas

b1c9g76 commented 11 years ago

Thanks very much for the reply. As you can see I'm new to json.

What I really want to do is subscribe to binary data. Is that possible natively in webdis?

Otherwise, I might just base64 encode instead.

Cheers, Brad

nicolasff commented 11 years ago

@b1c9g76 By "subscribe", do you mean receive events using a pub/sub channel? If so, it is possible but I would advise using base64 encoding to make sure your JS application (if that's the client code) can read the data without issues.