为什么Wget在其HTTP请求中有主机头? [英] Why does Wget have Host Header in its HTTP request?

查看:561
本文介绍了为什么Wget在其HTTP请求中有主机头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP / 1.0和HTTP / 1.1之间的主要区别在于HTTP / 1.1中包含必需 主机标头(来源:HTTP Pocket Reference - O'reilly )。

The main difference between HTTP/1.0 and HTTP/1.1 is that HTTP/1.1 has a mandatory Host header in it (source: HTTP Pocket Reference - O'reilly).

那么,为什么使用HTTP / 1.0协议的Wget中有一个主机头?

So, why is that Wget, which uses the HTTP/1.0 protocol, has a host header in it?

我使用 netcat 输出Wget:

GET / HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 127.0.0.1:10101
Connection: Keep-Alive

很明显Wget使用HTTP / 1.0协议版本,如何在其中有主机头?或者我对HTTP协议的理解有问题吗?

As it is clear that Wget uses the HTTP/1.0 protocol version, how can it have a host header in it? Or am I getting somewhere wrong with my understanding of HTTP protocol?

即使HTTP / 1.0在其HTTP请求中可以有Host Header,wget背后的原因也是什么使用HTTP / 1.0协议,而HTTP / 1.1也可以用来代替它?

And even if HTTP/1.0 can has Host Header in its HTTP request, what can be the reason behind wget using HTTP/1.0 protocol while HTTP/1.1 can also be used in place of that?

推荐答案

主机头被添加为HTTP / 1.0的可选添加很早就意识到这是允许一台服务器为多个域提供页面的唯一方法。 wget使用带有Host的HTTP / 1.0作为与最大站点数量兼容的方式,其中一些站点即使需要主机也不响应HTTP / 1.1。

The Host header was added as an "optional" addition to HTTP/1.0 very early on when it was realized this was the only way to allow one server to serve up pages for multiple domains. wget uses HTTP/1.0 with Host as the way to be compatible with the maximum number of sites, some of which don't respond to HTTP/1.1 even though they require Host.

这篇关于为什么Wget在其HTTP请求中有主机头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆