I have a very simple netcat webserver set up to display the /etc/motd
file for some machines, which works fine in Firefox, but intermittently fails in Chrome. I suspect it's an HTTP header / caching issue, but I'm not sure what I need to do to make Chrome behave.
My script:
#!/bin/bash
while true
do {
echo -e "HTTP/1.1 200 OK\r\nContent-Length: $(cat -s /etc/motd | wc -c)\r\nContent-Type: text/plain\r\n\r\n"
cat -s /etc/motd;
} | nc -l 2020
done
Which serves up:
HTTP/1.1 200 OK
Content-Length: 252
Content-Type: text/plain
.../etc/motd file contents....
Firefox seems to handle this fine, as does Chrome sometimes, but other times it returns:
This webpage is not available
Google Chrome's connection attempt to machine.example.com was rejected. The website may be down, or your network may not be properly configured.
I haven't seen any particular pattern causing the connection to fail, but my current theory is there's some sort of additional header Chrome expects to see, or perhaps the connection is being closed abruptly which Chrome assumes means the machine is down and doesn't actually re-try it.