I'm building a web server from scratch for fun and I am noticing some strange behaviors from Chrome. The request I get from Chrome for a GET request to / looks like this:
GET / HTTP/1.1
Host: localhost:8000
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Nothing special, but it also make another request to my server and it doesn't send anything, which results in my server waiting for an incoming message forever.
This behavior is not found with Safari. I have set the server to respond with 403 to every single request, but the persistent connection remains. What is the purpose of this connection and how should I handle it? Am I missing something from the HTTP protocol?