Skip to content

Commit

Permalink
fix: update computation for payload length offset (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
eWert-Online authored Aug 1, 2024
1 parent a3db363 commit f982c11
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 f982c11

Please sign in to comment.