def encode_ros_handshake_header(header):
 fields = [('%s=%s' % (k, v)) for (k, v) in header.items()]
 if (python3 == 0):
  s = ''.join([('%s%s' % (struct.pack('<I', len(f)), f)) for f in fields])
  return (struct.pack('<I', len(s)) + s)
 else:
  s = ''.join([(struct.pack('<I', len(f)) + f.encode('utf-8')) for f in fields])
  return (struct.pack('<I', len(s)) + s)

def encode_ros_handshake_header ( header ) : fields = [ ( '%s=%s' % ( k , v ) ) for ( k , v ) in header . items ( ) ] if ( python3 == 0 ) : s = '' . join ( [ ( '%s%s' % ( struct . pack ( '<I' , len ( f ) ) , f ) ) for f in fields ] ) return ( struct . pack ( '<I' , len ( s ) ) + s ) else : s = '' . join ( [ ( struct . pack ( '<I' , len ( f ) ) + f . encode ( 'utf-8' ) ) for f in fields ] ) return ( struct . pack ( '<I' , len ( s ) ) + s )
encode ros handshake header as a byte string .