nginx的一个bug:
这样的一个请求:
GET / HTTP/1.1\r\n
Host:\r\n
\r\n
这个请求按照http1.1规范来看,应该是正确的,但是却返回400 Bad Request错误:
HTTP/1.1 400 Bad Request
Server: nginx/0.8.18
Date: Fri, 22 Mar 2019 14:56:14 GMT
Content-Type: text/html
Content-Length: 173
Connection: close
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/0.8.18</center>
</body>
</html>
如果Host头随便指定一个值,就正确了:
GET / HTTP/1.1\r\n
Host:abc\r\n
\r\n
返回:
HTTP/1.1 200 OK
Server: nginx/0.8.18
Date: Fri, 22 Mar 2019 15:00:17 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Wed, 30 Aug 2006 06:39:18 GMT
Connection: keep-alive
Accept-Ranges: bytes
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
</body>
</html>