firecamp-io / firecamp

VSCode for APIs, Postman Alternative.
https://firecamp.dev
317 stars 22 forks source link

ArrayBuffer data is sent up as the ascii equivalent string instead of the actual binary data #143

Closed chris-schmitz closed 3 years ago

chris-schmitz commented 3 years ago

Describe the bug I'm trying to send an ArrayBuffer up to my server, but the data that ends up isn't the actual binary data, it's the ascii ascii character equivalent of the binary data. i.e. if I tried to send up 00000001, it would be sent up as a string. The actual data going up would be 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x31 since 0x30 is the ascii equivalent of the character 0 and 0x31 is the string character of 1.

TBH I could be using the tool wrong. I couldn't find a definitive explanation of how to send the ArrayBuffer, so I'm assuming I just provide the raw data.

To Reproduce Steps to reproduce the behavior:

  1. Start a websocket server
  2. Point firecamp at the server and connect
  3. Change the message type to an ArrayBuffer of any size
  4. Send the message
  5. On the server, dump the message and look at the hex values in the buffer, they'll be for the ascii codes and not the actual binary information sent

Expected behavior I'd expect the data being sent up to be the binary data from the buffer.

Screenshots 0r Video sending binary array1 smoother vid version of the recording can be found here

Platform (please complete the following information):

welcome[bot] commented 3 years ago

Welcome to the Firecamp! Thanks and congrats for opening your very first issue in Firecamp. Join the Discord community here https://discord.gg/8hRaqhK Hope you have a great time here :)

Nishchit14 commented 3 years ago

@chris-schmitz Have you tried the following snippets at your WS server?

ws.binaryType = "arraybuffer"
ws.on('message', data => {
  console.log(data);
})

Here is the API reference


Default ws server receives a binary message in nodebuffer

  1. if you want the message in arraybuffer then set ws.binaryType='arraybuffer'
  2. if you want the message in blob then set ws.binaryType='blob'

Similar issue on ws repo

chris-schmitz commented 3 years ago

I tried adding that setting but I'm still seeing utf encoded values.

Screen Shot 2020-12-26 at 8 17 34 AM

That said, I didn't read the linked issue in depth yet, I'll review that more and see if it has more detail that I can dig into.

Nishchit14 commented 3 years ago

@chris-schmitz Can you please confirm this issue? It's been shipped under the Canary v2 RC-8 release. If you think anything can still be improved then please let us know :)

Nishchit14 commented 3 years ago

Firecamp v2.0 released.