I needed to make and transfer a disk device image from a remote VM into my local PC I decided netcat (BSD variant is what I had available) was good enough to emulate the simplest of HTTP servers.

True One-liner

Transferring a file, for instance disk.img is as easy as this on the server side:

echo -ne 'HTTP/1.0 200 OK\r\n\r\n' | cat - disk.img | nc -Nvl 0.0.0.0 8888

Then on the client side you head to any file on the server with wget or any browser:

wget 'http://my.host.name:8888/disk.img'

Two-liner

If we want to use cat stdin for any other purpose, for instance gzip compression on the fly, it is easier to just put the HTTP response on a file as to free the pipeline. So our server side will now look like this:

echo -ne 'HTTP/1.0 200 OK\r\n\r\n' >response.txt
gzip -9cf /dev/sda | cat response.txt - | nc -Nvl 0.0.0.0 8888

With python 3

If python 3 is available, and I have many files laying around, this option is the most convenient for sharing the current directory.

python3 -m http.server 8888