Catching download filename of wget or cURL command?

I’ve been trying to figure out how to “catch” the filename of a downloaded file via wget or curl commands in a shell script.

What I’d like (and what seems impossible) is something like this:

newfilename=$(wget --content-disposition --trust-server-names --timestamping "${myurl}")
xattr -w user.download.url "${myurl}" "${newfilename}"

or with curl:

newfilename=$(curl --continue-at - --compressed --remote-name-all --remote-header-name --remote-time "${myurl}")
xattr -w user.download.url "${myurl}" "${newfilename}"

Now for some reason, I guess security, neither command seems willing to return the server-provided filename (in case it could contain remote code injection)? But that makes little sense to me when the same command is perfectly willing to use that remote filename string to create a file on disk?

Is there a way to do this, if necessary through some workaround that checks the destination directory for a created file via inotify watch?