3 ms·
Don't forget bash. #!/bin/bash while :; do nc -l 80 < index.html; done
by zikduruqe 1y ago
Don't forget bash.
#!/bin/bash
while :; do nc -l 80 < index.html; done
- xmodem 1y agoI was about to down-vote you, but that would be unfair, as this has roughly the typical level of correctness of most bash scripts.
- rollcat 1y agoIt's absolutely (almost) correct! HTTP/0.9 does not require you to send back a status code or any headers. Some modern web servers even recognise a lone "GET /" to mean HTTP/0.9 and will respond accordingly.
- xmodem 1y agoThis is exactly my point - it successfully accomplishes a very specific task, in a way that is fragile and context dependent, and completely fails to handle any errors or edge cases, or reckon with any complexity at all.
- vFunct 1y agoThis is hilarious
- creatonez 1y agoFor anyone baffled by this: This works because HTTP/0.9 (just called "HTTP" at the time) worked in an extremely simple way, and browsers mostly retained compatibility for this. HTTP/0.9 web browser sends: GET / Netcat sends: <!doctype html> ... Nowadays a browser will send `GET / HTTP/1.1` and then a bunch of headers, which a true HTTP/0.9 server may be able to filter out and ignore, but of course this script will just send the document and the browser will still assume it's a legacy server.