curl - change the host for http and https requests

For example, if you have a site on your localhost with a domain.tld hostname and you wish to have curl request without adding the hostname in /etc/hosts (maybe you have sudo restrictions), you can:

curl -H "Host: domain.tld" http://127.0.0.1/
or:
curl --header "Host: domain.tld" http://127.0.0.1/
The Host: header modification is not enough when communication with a server via https. An https server also needs to get the server name provided already in the TLS handshake.
For this case the --resolve command line option can help:
curl --resolve domain.tld:443:127.0.0.1 https://domain.tld/