Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] payloads of >64K are cut off at the beginning #62

Closed
eWert-Online opened this issue Jul 8, 2024 · 2 comments · Fixed by #63
Closed

[BUG] payloads of >64K are cut off at the beginning #62

eWert-Online opened this issue Jul 8, 2024 · 2 comments · Fixed by #63

Comments

@eWert-Online
Copy link
Contributor

I am trying to use httpun-ws as a websocket client (through the latest master version of piaf).
When recieving messages with a length of >= 64K, the message gets cut off at the beginning.

I investigated a bit and I think the error is originating from the payload_offset_of_bits function, which maybe computes the length offset too large.

I added a few logs, which give me the following values:

payload length: 66225

initial_offset: 2
mask_offset: 0
length_offset: 32

The length_offset seems a bit excessive, as for smaller messages it is 0 or 2.

The length computed with let length = bits land 0b01111111 in is "127". As soon as I reduce the length of the message to less than 64K (so the length is "126" or less), everything works fine.

@eWert-Online
Copy link
Contributor Author

When changing the computation of the length offset to this...

let length_offset  =
  let length = bits land 0b01111111 in
  if length = 127 then 8
  else if length = 126 then 2
  else 0
in

...everything seems to be working fine. I don't know if this is a good solution though 😄

@anmonteiro
Copy link
Owner

Thanks, I'll have to take a closer look at this and #63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants