GithubHelp home page GithubHelp logo

mcanthony / nodeuv-http Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heapwolf/cxx-http

1.0 2.0 0.0 1.14 MB

A simple http library in c++ backed by libuv and http-parser.

License: MIT License

Makefile 4.69% Batchfile 1.82% Python 6.97% C++ 86.52%

nodeuv-http's Introduction

SYNOPSIS

A simple http server backed by libuv and http-parser.

EXAMPLE

SERVER (API)

#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)

#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

valgrind --leak-check=yes --track-origins=yes --dsymutil=yes ./server

BUILD

make

nodeuv-http's People

Contributors

groundwater avatar heapwolf avatar jwerle avatar peters avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.