def set_xattr(self, path, xattr_name, xattr_value, flag, **kwargs):
        """Set an xattr of a file or directory.

        :param xattr_name: The name must be prefixed with the namespace followed by ``.``. For
            example, ``user.attr``.
        :param flag: ``CREATE`` or ``REPLACE``
        """
        kwargs['xattr.name'] = xattr_name
        kwargs['xattr.value'] = xattr_value
        response = self._put(path, 'SETXATTR', flag=flag, **kwargs)
        assert not response.content