code: def parse_frame(frame):
      
      f = Frame()
      if frame == b'\x0a':
          f.cmd = 'heartbeat'
          return f
  
      mat = PREAMBLE_END_RE.search(frame)
      if mat:
          preamble_end = mat.start()
          body_start = mat.end()
      else:
          preamble_end = len(frame)
          body_start = preamble_end
      preamble = decode(frame[0:preamble_end])
      preamble_lines = LINE_END_RE.split(preamble)
      preamble_len = len(preamble_lines)
      f.body = frame[body_start:]
  
      # Skip any leading newlines
      first_line = 0
      while first_line < preamble_len and len(preamble_lines[first_line]) == 0:
          first_line += 1
  
      if first_line >= preamble_len:
          return None
  
      # Extract frame type/command
      f.cmd = preamble_lines[first_line]
  
      # Put headers into a key/value map
      f.headers = parse_headers(preamble_lines, first_line + 1)
  
      return f
docs: Parse a STOMP frame into a Frame object.
  
      :param bytes frame: the frame received from the server (as a byte string)
  
      :rtype: Frame