#web #web-server #server

nightly app wesers

a simple HTTP/HTTPS server in Rust

6 releases (3 breaking)

Uses old Rust 2015

0.4.1 Aug 3, 2016
0.4.0 Aug 3, 2016
0.3.1 Jul 9, 2016
0.2.0 Jul 7, 2016
0.1.0 Jul 7, 2016

#367 in #web-server

AGPL-3.0

2.5MB
623 lines

Contains (ELF exe/lib, 3.5MB) wesers

wesers - a simple HTTP/HTTPS server in Rust

// 127.0.0.1 - - [03/Aug/2016 12:15:30] "GET /favicon.ico HTTP/1.1" 404 -

need request time, HTTP version

Table of Contents

Installation

(You need to compile with nightly, now)

If you want to build from source, make sure you are using nightly toolchain !

Without HTTPS support

Install with

cargo install --git https://github.com/wdv4758h/wesers

or

cargo install --git https://github.com/wdv4758h/wesers --tag v0.4.1

If you want to download prebuilt binary, you can visit GitHub's release page

With HTTPS support

Install with

cargo install --git https://github.com/wdv4758h/wesers --features https

or

cargo install --git https://github.com/wdv4758h/wesers --tag v0.4.1 --features https

Usage

$ wesers --help
wesers 0.4.1
Chiu-Hsiang Hsu <wdv4758h@gmail.com>
a simple HTTP/HTTPS server in Rust

USAGE:
    wesers [FLAGS] [OPTIONS]

FLAGS:
    -h, --help       Prints help information
        --https      use HTTPS instead of HTTP
    -V, --version    Prints version information

OPTIONS:
        --cert <cert>            SSL certificate file (needed for HTTPS)
        --index <index>          auto detect index.html [default: true]
        --ip <ip>                binding IP [default: 127.0.0.1]
        --key <key>              SSL key file (needed for HTTPS)
        --port <port>            binding port [default: 8000]
        --root <root>            root directory [default: .]
        --template <template>    HTML template path

run :

$ wesers
Simple HTTP Server running on http://127.0.0.1:8000/
127.0.0.1:54400 GET http://127.0.0.1:8000/ -> 200 OK (0.268528 ms)

run with custom address and HTML template :

$ wesers --ip 127.0.0.1 --port 8080 --template ./custom.mustache
Simple HTTP Server running on http://127.0.0.1:8080/

run in HTTPS :

$ wesers --https --cert mycert.pem --key mykey.pem
Simple HTTP Server running on https://127.0.0.1:8000/

Binary Size

x86_64 Linux:

Filename Version Stripped ? Size (Bytes) Size (MB)
wesers v0.4.1 No 3573904 3.5M
wesers v0.4.1 Yes 2769832 2.7M

Benchmarks

This is a simple load testing by Herd (Just a simple test, not indicate a lot)

# Running both herd and wesers on Intel Core i5-2400 with 4GB RAM
$ ./target/release/herd -t 4 -r 1000 http://127.0.0.1:8000

...
Spawning virtual user 1
...
Spawning virtual user 3
...
I made a total of 4000 requests, the mean response time was: 0.00042591915919911117 seconds.

Changelog

Not Implemented Yet (Plan)

  • more files information (type, size, last modified time)
  • more documentation
  • QR code support
  • optional userdir
  • support limit request times
  • RESTful API for files and directories
  • can run as CGI server
  • template live reload
  • handle POST for upload files
  • Android support
  • more template engine support
  • fix everything discover by linter (e.g. clippy)
  • code refactoring to improve performance
  • reduce binary size
  • unicode url support (issue https://github.com/iron/staticfile/issues/76)
  • HTTP2 support

v0.4.1 (2016-08-03)

Fix
  • HTTPS build

v0.4.0 (2016-08-03)

Features
  • log client IP
  • update all dependencies

v0.3.1 (2016-07-09)

Fix
  • make HTTPS optional (because of the dependency of OpenSSL)

v0.3.0 (2016-07-08)

Features
  • custom HTML template support (with mustache )
  • custom root directory support
  • HTTPS support (with OpenSSL)

v0.2.0 (2016-07-08)

Features
  • Bash completion by clap
  • optional index.html detection
  • handle 404 better

v0.1.0 (2016-07-07)

Features
  • serve static files
  • list files in directory

Notice

I've only tested on my x86_64 Linux. Other platforms are built by CI. If they don't work properly, please tell me.

Developement

Making Release

  1. update version in src/arguments.yml
  2. update version in Cargo.toml
  3. update version in Cargo.lock
  4. add git tag

Dependency of Shared Libraries

x86_64, Linux, no HTTPS

$ ldd ./target/release/wesers
        linux-vdso.so.1 (0x00007fff05f4c000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f1531e71000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1531c54000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f1531a3e000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f153169d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1532075000)

x86_64, Linux, with HTTPS

$ ldd ./target/release/wesers
        linux-vdso.so.1 (0x00007fffdbe85000)
        libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f168b810000)
        libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f168b399000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f168b195000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f168af78000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f168ad62000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f168a9c1000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f168ba81000)

x86_64, Linux, musl, no HTTPS

$ ldd ./target/x86_64-unknown-linux-musl/release/wesers
        not a dynamic executable

x86_64, Linux, musl, with HTTPS

$ ldd ./target/x86_64-unknown-linux-musl/release/wesers
        linux-vdso.so.1 (0x00007ffc55496000)
        libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f69cb9c8000)
        libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f69cb551000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f69cb1b0000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f69cafac000)
        /lib/ld64.so.1 (0x00007f69cbc39000)

Special Thanks

License

wesers is licensed under the AGPL License - see the LICENSE file for details

Dependencies

~5.5–7.5MB
~165K SLoC