4 ms·
The 400 error is just the web server complaining that there is no web site to deliver to you for that hostname. It isn't complaining about the hostname being in
by joosters 14y ago
The 400 error is just the web server complaining that there is no web site to deliver to you for that hostname. It isn't complaining about the hostname being invalid, per se.
- pilif 14y agoI thought so too, but then I made a little experiment: pilif@shion:~$ curl -I -H "Host: example.com" http://198.252.206.16/ HTTP/1.1 404 Not Found Content-Length: 4129 Date: Sat, 16 Mar 2013 12:28:22 GMT vs. pilif@shion:~$ curl -I -H "Host: example.com." http://198.252.206.16/ HTTP/1.1 400 Bad Request Content-Length: 334 Content-Type: text/html; charset=us-ascii Date: Sat, 16 Mar 2013 12:28:56 GMT The IP is the one from stackoverflow.com. When querying for a host they are not configured (try any), you will get a 404 plus an explanation page that the selected Q&A community doesn't exist. When you try the same host with a trailing dot, you get a generic IIS error 400. This is too much of a coincidence and I value it as a strong sign that my hypothesis might be correct. I have no IIS at my disposal to replicate paulbeattie's experiment, but the outcome he described further helps confirming my suspicion (no matter the downvotes he got) Same experiment works with microsoft.com too: pilif@shion:~$ curl -I -H "Host: example.com." http://65.55.57.27/ HTTP/1.1 400 Bad Request Content-Length: 334 Content-Type: text/html; charset=us-ascii Server: Microsoft-HTTPAPI/2.0 Date: Sat, 16 Mar 2013 12:35:10 GMT Connection: close pilif@shion:~$ curl -I -H "Host: example.com" http://65.55.57.27/ HTTP/1.1 200 OK Cache-Control: private Content-Length: 0 Server: Microsoft-IIS/8.0 (snip)
- joosters 14y agoThat's odd, I would have thought that '404 Not Found' would be the wrong response to send, although you could argue either way. I used to develop a web server ages ago (Zeus Web Server), it would try and match the Host: header against all the sites it was configured to server, and if none matched, it would send a 400 error back. (Incidentally, it would happily strip off the trailing dot from the hostname)