Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在发送一个 curl 请求,但我没有明确设置主机头。远程 url 接收到的主机头是什么?它会是我网站的域,还是会自动成为远程 url 的域?
标Host头是根据您请求的 URL 自动设置的。
Host
根据定义,它是远程 URL 的 Internet 主机名。
如果你不设置它,远程服务器将不会收到它。如果您以 HTTP/1.1 的形式发送请求,服务器应该将其视为格式错误的请求,因此您可能会收到错误代码。
但是,如果后端(例如 Apache)在将请求传递给脚本之前执行了一些处理,它可能会根据自己的逻辑进行设置。