I have finished the server TODOS and all seem to be working. I realized that probably the least explained part of the TODOs was the most important 3 lines of code (at least for me). It's this part:
each of which is terminated with CRLF (i.e., \r\n), which are followed after a single blank line (i.e., an additional CRLF) by the bytes of the file itself, whereby %i represents the file’s size in bytes and %s represents the file’s MIME type.
If I DO NOT implement that extra CRLF, I cannot see any static content (eg: html) using Chrome, despite the fact that telnet seems to be working just fine. For instance, calling cat.html via telnet would show the following:
GET /cat.html HTTP/1.1 HTTP/1.1 200 OK Connection: close Content-Length: 156 Content-type: text/html <!DOCTYPE html> <html> <head> <title>Happy Cat</title> </head> <body> <img alt="Happy Cat" src="cat.jpg"/> </body> </html> Connection closed by foreign host.
But loading cat.html via Chrome shows nothing. As soon as I implement just that additional CRLF in the static content code, then everything works great. I cannot wrap my head around this? Could someone explain that in the context of server???