parameters: (header_str)
return_statement: return d
docstring: Decode serialized ROS handshake header into a Python dictionary
  
      header is a list of string key=value pairs, each prefixed by a
      4-byte length field. It is preceeded by a 4-byte length field for
      the entire header.
      
      :param header_str: encoded header string. May contain extra data at the end, ``str``
      :returns: key value pairs encoded in \a header_str, ``{str: str}``
docstring_summary: Decode serialized ROS handshake header into a Python dictionary
docstring_tokens: Decode serialized ROS handshake header into a Python dictionary
function: def decode_ros_handshake_header(header_str):
      """
      Decode serialized ROS handshake header into a Python dictionary
  
      header is a list of string key=value pairs, each prefixed by a
      4-byte length field. It is preceeded by a 4-byte length field for
      the entire header.
      
      :param header_str: encoded header string. May contain extra data at the end, ``str``
      :returns: key value pairs encoded in \a header_str, ``{str: str}``
      """
      (size, ) = struct.unpack('<I', header_str[0:4])
      size += 4 # add in 4 to include size of size field
      header_len = len(header_str)
      if size > header_len:
          raise ROSHandshakeException("Incomplete header. Expected %s bytes but only have %s"%((size+4), header_len))
  
      d = {}
      start = 4
      while start < size:
          (field_size, ) = struct.unpack('<I', header_str[start:start+4])
          if field_size == 0:
              raise ROSHandshakeException("Invalid 0-length handshake header field")
          start += field_size + 4
          if start > size:
              raise ROSHandshakeException("Invalid line length in handshake header: %s"%size)
          line = header_str[start-field_size:start]
          
          #python3 compatibility
          if python3 == 1:
              line = line.decode()
          
          idx = line.find("=")
          if idx < 0:
              raise ROSHandshakeException("Invalid line in handshake header: [%s]"%line)
          key = line[:idx]
          value = line[idx+1:]
          d[key.strip()] = value
      return d
function_tokens: def decode_ros_handshake_header ( header_str ) : ( size , ) = struct . unpack ( '<I' , header_str [ 0 : 4 ] ) size += 4 # add in 4 to include size of size field header_len = len ( header_str ) if size > header_len : raise ROSHandshakeException ( "Incomplete header. Expected %s bytes but only have %s" % ( ( size + 4 ) , header_len ) ) d = { } start = 4 while start < size : ( field_size , ) = struct . unpack ( '<I' , header_str [ start : start + 4 ] ) if field_size == 0 : raise ROSHandshakeException ( "Invalid 0-length handshake header field" ) start += field_size + 4 if start > size : raise ROSHandshakeException ( "Invalid line length in handshake header: %s" % size ) line = header_str [ start - field_size : start ] #python3 compatibility if python3 == 1 : line = line . decode ( ) idx = line . find ( "=" ) if idx < 0 : raise ROSHandshakeException ( "Invalid line in handshake header: [%s]" % line ) key = line [ : idx ] value = line [ idx + 1 : ] d [ key . strip ( ) ] = value return d