Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heapwolf/cxx-http
A simple http library in c++ backed by libuv and http-parser.
https://github.com/heapwolf/cxx-http
Last synced: 11 days ago
JSON representation
A simple http library in c++ backed by libuv and http-parser.
- Host: GitHub
- URL: https://github.com/heapwolf/cxx-http
- Owner: heapwolf
- License: mit
- Created: 2014-08-30T17:15:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-02-06T02:00:28.000Z (almost 6 years ago)
- Last Synced: 2024-10-30T10:02:35.259Z (13 days ago)
- Language: C++
- Homepage:
- Size: 377 KB
- Stars: 183
- Watchers: 15
- Forks: 37
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SYNOPSIS
A simple http server backed by [`libuv`](https://github.com/joyent/libuv)
and [`http-parser`](https://github.com/joyent/http-parser).# EXAMPLE
## SERVER ([API](https://github.com/hij1nx/nodeuv-http/wiki/Server-Documentation))
```cpp#include "http.h"
using namespace http;
int main () {
Server server([](auto &req, auto &res) {
res.setStatus(200);
res.setHeader("Content-Type", "text/plain");
res.setHeader("Connection", "keep-alive");res << req.method << " " << req.url << endl;
});
server.listen("0.0.0.0", 8000);
}
```## CLIENT ([API](https://github.com/hij1nx/nodeuv-http/wiki/Client-Documentation))
```cpp#include "http.h"
using namespace http;
int main () {
Client client("http://google.com", [](auto &res) {
cout << res.body << endl;
});}
```# PERFORMANCE
Just for fun. Without any real statistical significance, here are
some quick averages from apache ab, run on an old macbook air. Also
neat is that `nodeuv-http` server uses about `400KB` of memory
(compared to Node.js' `10-15MB`).### nodeuv-http
```
Requests per second: 16333.46 [#/sec] (mean)
```### node.js
```
Requests per second: 3366.41 [#/sec] (mean)
```# COMPATIBILITY
Runs on `OSX`, `Linux` and `Windows`.# DEVELOPMENT
## REQUIREMENTS
### OSX, Linux
This project is made to work with C++11/14. So you'll either need
fairly recent, stable releases of GCC (`~4.8.x`) or Clang (`~4.2.x`).### Windows
Windows doesn't have a compatible make tool. So you'll have to run
this `build.bat` file to clone repos and run `gyp`.## DEBUGGING
### VALGRIND
```bash
valgrind --leak-check=yes --track-origins=yes --dsymutil=yes ./server
```## BUILD
```bash
make
```