A small, lightweight and easy-to-use HTTP/1.0:ish web server for static files. It is intended to be used as a quick one shot web server for sharing files on a LAN or as a local server for client side web development.
Supported HTTP methods are
HEAD. Connections are always
closed after one request. The response always includes HTTP headers
even if the request is in old HTTP/0.9 style, for example
File transfers should be reasonable efficient as they are implemented
sendfile() on Linux and
(Windows 9x has to fallback to a read() & send() loop.) Large files
(over 2 GiB) have not been tested and probably will not work.
IPv6 is not currently supported (patches are welcome.) There will "never" be HTTPS (SSL/TLS) support.
I have yet to find a web browser or a command line client that does not work nicely with websrv even though I know it is not standard compliant by any means.
websrv has been primarily developed on Linux and tested on various Windows versions ranging from Windows 98 to Windows 10, as well as FreeBSD 10.
It requires about 1.5 MiB of free memory. More is of course better so that OS can use it for caching the file system.
The provided Windows .exe is compiled for i686 and will not work with
anything less than a Intel Pentium Pro / Pentium II / AMD K6. It works
fine in 64-bit Windows. You can (re)compile for i586 by deleting the
-march=i686 in the
Compiling from source requires a C compiler with working C99 support and GNU Make. websrv has been successfully compiled with both GCC and Clang on Linux and FreeBSD, and with MinGW on Windows.
gmake) should work and
compiles a debug build. See
Makefile for more.
There are no configuration files. Few options can be set with command line parameters:
Usage: websrv [-h|--help] [-a x.x.x.x] [-p n] [-t n] [-i idx.htm] [-m mime.txt] [dir] Where: -h, --help Print usage -a x.x.x.x Set listen IPv4 address (default: 127.0.0.1) -p n Set listen TCP port (default: 8000) -t n Set number of threads (default: 4) -i idx.htm Set default page(s) (default: index.html,index.htm,default.html,default.htm) -m mime.txt Load MIME table from a file (default: built-in) dir Set webroot (default: .)
The default when run without arguments (or double clicked in Windows)
is to serve files from the current directory for localhost only at
http://127.0.0.1:8000/. In the absense of an index file,
websrv will list the directory contents. There is a built-in favicon
if one is not found in the root directory.
MIME.txt for more about the MIME table file. (The one
exception to "no configuration files" ;-)
Production build prints a couple of message lines at start and the web log style lines for each request to stdout. Any errors are printed to stderr.
Copyright © 2016 Väinö Helminen
Licensed under a MIT license. See included