def METHOD_NAME(conn, postfix):
    read = b''
    assert isinstance(postfix, bytes)
    while not read.endswith(postfix):
        result = conn.recv(1)
        if not result:
            raise AssertionError('Connection ended before %r. Data read:\n%r' % (postfix, read))
        read += result
    return read if isinstance(read, str) else read.decode('utf-8')