Skip to content

Commit

Permalink
fix: update computation for payload length offset
Browse files Browse the repository at this point in the history
  • Loading branch information
eWert-Online committed Jul 9, 2024
1 parent a3bdce5 commit fec8721
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ let payload_offset_of_bits bits =
let initial_offset = 2 in
let mask_offset = (bits land (1 lsl 7)) lsr (7 - 2) in
let length_offset =
let length = bits land 0b01111111 in
if length < 126
then 0
else 2 lsl ((length land 0b1) lsl 2)
match bits land 0b01111111 with
| 127 -> 8
| 126 -> 2
| _ -> 0
in
initial_offset + mask_offset + length_offset
;;
Expand Down

0 comments on commit fec8721

Please sign in to comment.