There is an answer that serves a file over HTTP using nc
{ echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat some.file; } | nc -l -p 8080
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l -p 8080
A comment says:
Chrome won't stop throbbing unless you use the second nc command.
Also, not both of the nc commands show will quit after responding. You can keep restarting it with:
while :; do { echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l -p 8080; done
. Use ctrl+z to but it to sleep.
Does throbbing mean that a web browser keeps automatically reload the URL?
Is the purpose of the second nc command that adds Content-Length: $(wc -c <some.file)
to the first nc command to stop Chrome from throbbing?
URL http://IP:8080/
followed by nothing or anything will work in a web browser to get the file. Is this flexibility provided by HTTP protocol, nc
, or the web browser?
Thanks.