2018-01-12 05:16:05 +00:00
|
|
|
# libuhttpd([中文](/README_ZH.md))
|
2017-11-09 04:54:28 +00:00
|
|
|
|
2020-02-07 09:31:01 +00:00
|
|
|
[1]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=plastic
|
2018-01-21 11:15:09 +00:00
|
|
|
[2]: /LICENSE
|
|
|
|
[3]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=plastic
|
|
|
|
[4]: https://github.com/zhaojh329/libuhttpd/pulls
|
|
|
|
[5]: https://img.shields.io/badge/Issues-welcome-brightgreen.svg?style=plastic
|
|
|
|
[6]: https://github.com/zhaojh329/libuhttpd/issues/new
|
2020-12-26 17:18:27 +00:00
|
|
|
[7]: https://img.shields.io/badge/release-3.7.0-blue.svg?style=plastic
|
2018-01-21 11:15:09 +00:00
|
|
|
[8]: https://github.com/zhaojh329/libuhttpd/releases
|
2018-03-08 15:47:04 +00:00
|
|
|
[9]: https://travis-ci.org/zhaojh329/libuhttpd.svg?branch=master
|
|
|
|
[10]: https://travis-ci.org/zhaojh329/libuhttpd
|
2018-01-21 11:15:09 +00:00
|
|
|
|
|
|
|
[![license][1]][2]
|
|
|
|
[![PRs Welcome][3]][4]
|
|
|
|
[![Issue Welcome][5]][6]
|
|
|
|
[![Release Version][7]][8]
|
2018-03-08 15:47:04 +00:00
|
|
|
[![Build Status][9]][10]
|
2017-11-09 04:54:28 +00:00
|
|
|
|
2019-08-31 08:56:05 +00:00
|
|
|
[libev]: http://software.schmorp.de/pkg/libev.html
|
|
|
|
[http-parser]: https://github.com/nodejs/http-parser
|
2017-12-29 06:40:58 +00:00
|
|
|
[openssl]: https://github.com/openssl/openssl
|
2019-08-31 09:08:41 +00:00
|
|
|
[mbedtls]: https://github.com/ARMmbed/mbedtls
|
|
|
|
[wolfssl]: https://github.com/wolfSSL/wolfssl
|
2017-11-12 08:28:09 +00:00
|
|
|
|
2020-08-02 05:33:04 +00:00
|
|
|
A very flexible, lightweight and fully asynchronous HTTP server library based on [libev] and [http-parser] for Embedded Linux.
|
2017-11-11 11:06:51 +00:00
|
|
|
|
2017-11-10 11:16:47 +00:00
|
|
|
# Features
|
2018-02-09 16:42:38 +00:00
|
|
|
* Lightweight and fully asynchronous
|
2019-08-31 08:56:05 +00:00
|
|
|
* Use [libev] as its event backend
|
2018-01-03 02:50:49 +00:00
|
|
|
* Support HTTPS - OpenSSL, mbedtls and CyaSSl(wolfssl)
|
2021-01-01 10:39:28 +00:00
|
|
|
* Support HTTP pipelining
|
2020-12-20 10:17:13 +00:00
|
|
|
* Support IPv6
|
2020-03-13 16:23:37 +00:00
|
|
|
* Support plugin
|
2020-12-17 15:51:46 +00:00
|
|
|
* Support upload large file
|
2021-01-03 09:25:00 +00:00
|
|
|
* Support HTTP range requests
|
2021-01-03 08:19:24 +00:00
|
|
|
* Support multi-process model - The same multi-process model as Nginx
|
2018-01-03 02:50:49 +00:00
|
|
|
* Flexible - you can easily extend your application to have HTTP/HTTPS services
|
|
|
|
* Code structure is concise and understandable, also suitable for learning
|
|
|
|
|
2017-12-29 06:40:58 +00:00
|
|
|
# Dependencies
|
2021-01-01 10:39:28 +00:00
|
|
|
* [libev] - A full-featured and high-performance event loop
|
2021-01-01 08:02:47 +00:00
|
|
|
* [http-parser] - A high performance parser for HTTP messages written in C
|
2018-01-03 02:50:49 +00:00
|
|
|
* [mbedtls] - If you choose mbedtls as your SSL backend
|
2019-08-31 09:08:41 +00:00
|
|
|
* [wolfssl] - If you choose wolfssl as your SSL backend
|
2018-01-03 02:50:49 +00:00
|
|
|
* [openssl] - If you choose openssl as your SSL backend
|
2017-11-12 08:28:09 +00:00
|
|
|
|
2021-01-03 08:54:31 +00:00
|
|
|
# Benchmark
|
|
|
|
## Nginx
|
|
|
|
|
|
|
|
$ wrk -t4 -c400 -d10s http://localhost:80/test.html
|
|
|
|
Running 10s test @ http://localhost:80/test.html
|
|
|
|
4 threads and 400 connections
|
|
|
|
Thread Stats Avg Stdev Max +/- Stdev
|
|
|
|
Latency 3.54ms 7.32ms 224.58ms 93.30%
|
|
|
|
Req/Sec 40.63k 12.49k 96.29k 74.50%
|
|
|
|
1622012 requests in 10.05s, 385.09MB read
|
|
|
|
Requests/sec: 161390.39
|
|
|
|
Transfer/sec: 38.32MB
|
|
|
|
|
|
|
|
## libuhttpd
|
|
|
|
|
|
|
|
$ wrk -t4 -c400 -d10s http://localhost:8080/test.html
|
|
|
|
Running 10s test @ http://localhost:8080/test.html
|
|
|
|
4 threads and 400 connections
|
|
|
|
Thread Stats Avg Stdev Max +/- Stdev
|
|
|
|
Latency 2.12ms 3.01ms 31.30ms 89.26%
|
|
|
|
Req/Sec 70.87k 12.53k 142.54k 79.75%
|
|
|
|
2826394 requests in 10.05s, 547.18MB read
|
|
|
|
Requests/sec: 281328.83
|
|
|
|
Transfer/sec: 54.46MB
|
|
|
|
|
2017-12-30 04:41:43 +00:00
|
|
|
# Configure
|
2017-11-12 08:28:09 +00:00
|
|
|
See which configuration are supported
|
2018-02-19 06:14:20 +00:00
|
|
|
|
2017-12-30 04:41:43 +00:00
|
|
|
~/libuhttpd/$ mkdir build && cd build
|
2017-12-29 06:46:40 +00:00
|
|
|
~/libuhttpd/build$ cmake .. -L
|
|
|
|
~/libuhttpd/build$ cmake .. -LH
|
2017-12-30 04:41:43 +00:00
|
|
|
|
2017-12-30 09:42:50 +00:00
|
|
|
# Build and install
|
2017-12-30 04:41:43 +00:00
|
|
|
|
|
|
|
~/libuhttpd/build$ make && sudo make install
|
|
|
|
|
2018-01-05 13:46:03 +00:00
|
|
|
# Run Example
|
2017-11-12 08:28:09 +00:00
|
|
|
Run
|
|
|
|
|
2019-08-31 08:56:05 +00:00
|
|
|
~/libuhttpd/build$ ./example/example
|
2017-11-12 08:28:09 +00:00
|
|
|
|
2017-11-14 14:16:26 +00:00
|
|
|
Then use the command curl or browser to test
|
2017-11-12 08:28:09 +00:00
|
|
|
|
2019-08-31 08:56:05 +00:00
|
|
|
$ curl 'https://127.0.0.1:8000' -v
|
2018-01-04 04:46:48 +00:00
|
|
|
|
2018-03-11 04:38:36 +00:00
|
|
|
# Install on OpenWrt
|
|
|
|
opkg update
|
|
|
|
opkg list | grep libuhttpd
|
|
|
|
opkg install libuhttpd-nossl
|
2018-01-04 04:46:48 +00:00
|
|
|
|
2018-03-11 04:38:36 +00:00
|
|
|
If the install command fails, you can [compile it yourself](/BUILDOPENWRT.md).
|
2018-01-04 04:46:48 +00:00
|
|
|
|
2018-07-21 09:41:09 +00:00
|
|
|
# [Example](/example)
|
2017-11-10 11:16:47 +00:00
|
|
|
|
|
|
|
# Contributing
|
2017-12-29 03:44:03 +00:00
|
|
|
If you would like to help making [libuhttpd](https://github.com/zhaojh329/libuhttpd) better,
|
|
|
|
see the [CONTRIBUTING.md](https://github.com/zhaojh329/libuhttpd/blob/master/CONTRIBUTING.md) file.
|
2018-03-16 06:06:22 +00:00
|
|
|
|