def environ_to_message(environ):
    """
    WSGI environ -> ASGI message
    """
    message = {'method': environ['REQUEST_METHOD'].upper(), 'root_path':
        environ.get('SCRIPT_NAME', ''), 'path': environ.get('PATH_INFO', ''
        ), 'query_string': environ.get('QUERY_STRING', ''), 'http_version':
        environ.get('SERVER_PROTOCOL', 'http/1.0').split('/', 1)[-1],
        'scheme': environ.get('wsgi.url_scheme', 'http')}
    if 'REMOTE_ADDR' in environ and 'REMOTE_PORT' in environ:
        message['client'] = [environ['REMOTE_ADDR'], int(environ[
            'REMOTE_PORT'])]
    if 'SERVER_NAME' in environ and 'SERVER_PORT' in environ:
        message['server'] = [environ['SERVER_NAME'], int(environ[
            'SERVER_PORT'])]
    headers = []
    if environ.get('CONTENT_TYPE'):
        headers.append([b'content-type', environ['CONTENT_TYPE'].encode(
            'latin-1')])
    if environ.get('CONTENT_LENGTH'):
        headers.append([b'content-length', environ['CONTENT_LENGTH'].encode
            ('latin-1')])
    for key, val in environ.items():
        if key.startswith('HTTP_'):
            key_bytes = key[5:].replace('_', '-').upper().encode('latin-1')
            val_bytes = val.encode()
            headers.append([key_bytes, val_bytes])
    return message
