2017-12-30 01:27:06 +00:00
|
|
|
|
# libuhttpd
|
2017-11-30 00:46:38 +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
|
2021-01-11 13:41:47 +00:00
|
|
|
|
[7]: https://img.shields.io/badge/release-3.8.0-blue.svg?style=plastic
|
2018-01-21 11:15:09 +00:00
|
|
|
|
[8]: https://github.com/zhaojh329/libuhttpd/releases
|
2021-01-20 14:36:48 +00:00
|
|
|
|
[9]: https://github.com/zhaojh329/libuhttpd/workflows/build/badge.svg
|
2018-01-21 11:15:09 +00:00
|
|
|
|
|
|
|
|
|
[![license][1]][2]
|
|
|
|
|
[![PRs Welcome][3]][4]
|
|
|
|
|
[![Issue Welcome][5]][6]
|
|
|
|
|
[![Release Version][7]][8]
|
2021-01-20 14:36:48 +00:00
|
|
|
|
![Build Status][9]
|
2017-11-30 00:46:38 +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-30 00:46:38 +00:00
|
|
|
|
|
2020-08-02 05:33:04 +00:00
|
|
|
|
一个非常灵活的,轻量的,全异步的HTTP服务器C库,基于[libev]和[http-parser],主要用于嵌入式Linux。
|
2017-11-30 00:46:38 +00:00
|
|
|
|
|
|
|
|
|
# 特性
|
2018-02-09 16:42:38 +00:00
|
|
|
|
* 轻量、全异步
|
2019-08-31 08:56:05 +00:00
|
|
|
|
* 使用[libev]作为其事件后端
|
2018-01-03 02:50:49 +00:00
|
|
|
|
* 支持HTTPS - OpenSSL, mbedtls 和 CyaSSl(wolfssl)
|
2021-01-01 10:39:28 +00:00
|
|
|
|
* 支持 HTTP 流水线
|
2020-12-20 10:17:13 +00:00
|
|
|
|
* 支持 IPv6
|
2020-03-13 16:23:37 +00:00
|
|
|
|
* 支持插件
|
2020-12-17 15:51:46 +00:00
|
|
|
|
* 支持上传大文件
|
2021-01-03 09:25:00 +00:00
|
|
|
|
* 支持 HTTP 范围请求
|
2021-01-03 08:19:24 +00:00
|
|
|
|
* 支持多进程模型 - 和 Nginx 一样的多进程模型
|
2018-01-03 02:50:49 +00:00
|
|
|
|
* 可伸缩 - 你可以非常方便的扩展你的应用程序,使之具备HTTP/HTTPS服务
|
2017-11-30 00:46:38 +00:00
|
|
|
|
* 代码结构简洁通俗易懂,亦适合学习
|
2018-01-03 02:50:49 +00:00
|
|
|
|
|
2017-12-29 06:40:58 +00:00
|
|
|
|
# 依赖
|
2021-01-01 10:39:28 +00:00
|
|
|
|
* [libev] - 一个全功能和高性能的事件循环库
|
2021-01-01 08:02:47 +00:00
|
|
|
|
* [http-parser] - 一个用 C 语言编写的高性能的 HTTP 消息解析器
|
2018-01-03 02:50:49 +00:00
|
|
|
|
* [mbedtls] - 如果你选择mbedtls作为你的SSL后端
|
2019-08-31 09:08:41 +00:00
|
|
|
|
* [wolfssl] - 如果你选择wolfssl作为你的SSL后端
|
2018-01-03 02:50:49 +00:00
|
|
|
|
* [openssl] - 如果你选择openssl作为你的SSL后端
|
2017-11-30 00:46:38 +00:00
|
|
|
|
|
2021-01-03 08:54:31 +00:00
|
|
|
|
# 基准测试
|
|
|
|
|
## 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
|
|
|
|
# 配置
|
2017-11-30 00:46:38 +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
|
|
|
|
# 编译和安装
|
2017-12-30 04:41:43 +00:00
|
|
|
|
|
|
|
|
|
~/libuhttpd/build$ make && sudo make install
|
|
|
|
|
|
|
|
|
|
# 运行示例程序
|
2017-11-30 00:46:38 +00:00
|
|
|
|
运行
|
|
|
|
|
|
2021-01-08 16:01:32 +00:00
|
|
|
|
~/libuhttpd/build$ ./example/simple_server -v
|
2017-11-30 00:46:38 +00:00
|
|
|
|
|
|
|
|
|
然后使用命令curl或者浏览器进行测试
|
|
|
|
|
|
2019-08-31 08:56:05 +00:00
|
|
|
|
$ curl -k 'https://127.0.0.1:8000/hello'
|
2017-12-29 06:40:58 +00:00
|
|
|
|
|
2018-03-11 04:38:36 +00:00
|
|
|
|
# 安装到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
|
|
|
|
如果安装失败,你可以[自己编译](/BUILDOPENWRT_ZH.md)。
|
2018-01-04 04:46:48 +00:00
|
|
|
|
|
2018-07-21 09:41:09 +00:00
|
|
|
|
# [示例程序](/example)
|
2017-11-30 00:46:38 +00:00
|
|
|
|
|
|
|
|
|
# 贡献代码
|
2017-12-29 03:44:03 +00:00
|
|
|
|
如果你想帮助[libuhttpd](https://github.com/zhaojh329/libuhttpd)变得更好,请参考
|
|
|
|
|
[CONTRIBUTING_ZH.md](https://github.com/zhaojh329/libuhttpd/blob/master/CONTRIBUTING_ZH.md)。
|
2017-11-30 00:46:38 +00:00
|
|
|
|
|
2017-12-05 09:35:24 +00:00
|
|
|
|
# 技术交流
|
|
|
|
|
QQ群:153530783
|
2018-03-16 06:06:22 +00:00
|
|
|
|
|