class WebSocket::Driver::Hybi

def parse_length(octet)

def parse_length(octet)
  @frame.masked = (octet & MASK) == MASK
  @frame.length = (octet & LENGTH)
  if @frame.length >= 0 and @frame.length <= 125
    @stage = @frame.masked ? 3 : 4
    return unless check_frame_length
  else
    @stage = 2
    @frame.length_bytes = (@frame.length == 126) ? 2 : 8
  end
  if @require_masking and not @frame.masked
    return fail(:unacceptable, 'Received unmasked frame but masking is required')
  end
end