C++ API: http server with local dynamic or precompiled repository containers

Overview

libnavajo

Framework to develop easily web interfaces in your C++ applications

Libnavajo makes it easy to run an HTTP server into your own application, implement dynamic pages, and include all the web pages you want (local or compiled into your project)

Specifications :

  • Implementation is HTTP 1.1 compliant with SSL, X509 and HTTP authentification, compression Zlib...
  • Very fast with its fully configurable pthreads pool
  • Support for IPv4 and IPv6
  • Precompiler to include a web repository into your code
  • Generate dynamic and static contents
  • Cookies and advanced session management
  • HTML5 Websockets support
  • Multipart's Content support
  • Fully oriented object
  • Many examples included

Download and install :

git clone https://github.com/titi38/libnavajo.git

mkdir build

cd build

cmake ..

make

sudo make install

Notes:

Libnavajo is released under the CeCILL-C licence ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.txt )

If you want to support us or contribute, please contact [email protected]

Issues
  • Access POST request payload

    Access POST request payload

    Hello Thierry,

    I'm currently building a RESTfull api for a small project we have here.

    Building pages and adding them to the dynamic repository on-the-fly works well.

    However, I can't figure out how to retrieve the payload of a POST request ?

    Cheers,

    opened by spelle 9
  • Building with ustl

    Building with ustl

    Hello ! I did some changes to be able to compile this project with https://github.com/msharov/ustl it's on this fork https://github.com/mingodad/libnavajo , there is a codeblocks project file there for it.

    Cheers !

    opened by mingodad 6
  • On the fly page creation

    On the fly page creation

    Hello Thierry :-)

    me, again ;-)

    According to this page (https://en.wikipedia.org/wiki/Representational_state_transfer) for a POST within a collection, a new entry is created and then returned.

    This is what i do : m_dr.add( ssUrl.str(), new restKeySetPage( m_db, keySetId, m_dr ) ) ; response->forwardTo( ssUrl.str() ) ;

    However, I get a 404.

    I wondering if there is a kind of delay between the page creation and its availability ?

    Thanks a lot.

    opened by spelle 5
  • File corruption when using localRepository and a slow connection

    File corruption when using localRepository and a slow connection

    Hello, i'm trying to download a 10 MB file using localRepository object (no SSL). If my wget client is on same subnet, the download is very fast and no corruption occurs. If my wget client is on a distant network, with slow connection (300Kb/sec), then the corruption always happens. Note that there are no corruption when using httpd between the same hosts, so the slow connection can't be considered as the corruptor.

    regards

    opened by jcourtat 4
  • OPTIONS support

    OPTIONS support

    In order to support CORS for most browsers it would be great if METHOD OPTIONS support were included. Otherwise the setCORS doesn't work with most modern browsers.

    Thanks!

    opened by dgruhl 4
  • WebServer: add support of Authorization: Bearer in HTTP header

    WebServer: add support of Authorization: Bearer in HTTP header

    This patch implement some parts of RFC 6750 OAuth 2.0 Bearer Token Usage. Authorization of resource access through the use of a token is limited to token presence in header fields of HTTP request.

    Even if expiration date is not mandatory within tokens, i think most of the time tokens embeds such data to grant access to resources for a discrete period. That's why this patch focus on searching for an expiration date within the token, and store it in a map in case of successful token verification, to speed up next requests processing with same token.

    Since content of tokens is not standardized, callbacks must be provided to keep the token decode and checks outside of libnavajo.

    Signed-off-by: Julien Courtat [email protected]

    opened by jcourtat 4
  • Http response error can't be different of 404

    Http response error can't be different of 404

    Hello, thanks for you work on this library. I don't see how to build a response with the error code i want and the content i want. when i return false in the getPage() method, libnavajo automatically set HTTP error code to 404 and a default body with HTML is set in the body response. Am i right ? If this is the case, would you agree on a patch permitting such configuration ?

    regards

    Julien

    opened by jcourtat 4
  • libpam

    libpam

    Hi Thierry,

    I updated to Ubuntu 16.04. I had to reinstall everything. When compiling libnavajo, It made me think that maybe you should update README with a section like Pre-requisite for installing libpam0g-dev (ubuntu)

    $ sudo apt install libpam0g-dev

    Hth.

    Cheers,

    opened by spelle 4
  • SIGSEGV on WebServer::closeSocket()

    SIGSEGV on WebServer::closeSocket()

    Hello,

    I'm having an issue (SIGSEGV) within the WebServer::closeSocket()

    (gdb) bt
    #0  0x00007fffe80000a8 in ?? ()
    #1  0x00007ffff7bb16df in WebServer::closeSocket (client=0x7ffff001d620) at /home/sherpa/Workspaces/workspace-Arduino/libnavajo/src/WebServer.cc:1522
    #2  0x00007ffff7bb66dd in WebServer::freeClientSockData (c=0x7ffff001d620)
        at /home/sherpa/Workspaces/workspace-Arduino/libnavajo/include/libnavajo/WebServer.hh:49
    #3  0x00007ffff7bb0c7c in WebServer::poolThreadProcessing (this=0x61dd60) at /home/sherpa/Workspaces/workspace-Arduino/libnavajo/src/WebServer.cc:1350
    #4  0x00007ffff7bb6749 in WebServer::startPoolThread (t=0x61dd60) at /home/sherpa/Workspaces/workspace-Arduino/libnavajo/include/libnavajo/WebServer.hh:84
    #5  0x00007ffff73bb6aa in start_thread (arg=0x7ffff7f52700) at pthread_create.c:333
    #6  0x00007ffff70f0e9d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
    

    More specifically on following line : int n=SSL_shutdown(client->ssl);

    Certificate has been generated like this :

    $ openssl rsa -in privkey.pem > crt.pem    
    $ openssl x509 -in cert.pem >> crt.pem
    

    When commenting the webServer->setUseSSL(true, "crt.pem");, it works.

    Cheers,

    opened by spelle 4
  • Dynamic Repos

    Dynamic Repos

    Sorry for this cuestion, maybe not an issue, part of my ignorance, but i can´t add a dynamic list of repos readed from a config file.

    for (auto & path : statics) {
        		LocalRepository repo(config.get("www.statics."+ path + ".www",""), config.get("www.statics."+ path + ".path",""));
                webServer->addRepository(&repo);
     }
    

    Im trying to add dynamic, pushing it to a vector and pass pointer to webserver: quick and dirty:

    std::vector<LocalRepository> repositories;
    
    int i=0;
    for (auto & path : statics) {
        		LocalRepository repo(config.get("www.statics."+ path + ".www",""), config.get("www.statics."+ path + ".path",""));
                repositories.push_back(repo);
                LocalRepository rarr = repositories.at(i);
        		webServer->addRepository(&rarr);
                i++;
    }
    

    Thanks and sorry

    opened by codesian 2
  • More expansive

    More expansive "Allow" headers for CORS

    It seems JQuery/Chrome is a little pushy. It wants Allow Headers and Allow Methods. I found adding

          header += "Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept-Encoding, Accept-Language\r\n";
          header += "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS\r\n";
    

    to WebServer.cc makes it happy.

    opened by dgruhl 2
  • Fix SSL memory leaks in WebServer

    Fix SSL memory leaks in WebServer

    Three different memory leaks have been fixed:

    • sslCtx free on webserver exit
    • BIO free when SSL_new fails
    • the most important one, each time a SSL_accept fails, for exemple, if the client tries to connect without https, the leak happens for every connection attemps
    opened by jcourtat 0
  • memory leaks when http client tries to connect without SSL on a WebServer configured with SSL

    memory leaks when http client tries to connect without SSL on a WebServer configured with SSL

    Hello, Valgrind detected a big memory leak if the WebServer is configured with SSL but the client connect without SSL using a http://host/resource url for example. This memory leak is per request, meaning an attacker may flood the WebServer an cause program crash and OOM issues as well.

    opened by jcourtat 0
  • No multithread support with SSL

    No multithread support with SSL

    Hello, According to SSL documentation:

    OpenSSL can generally be used safely in multi-threaded applications provided that at least two callback functions are set, the locking_function and threadid_func. Note that OpenSSL is not completely thread-safe, and unfortunately not all global resources have the necessary locks. Further, the thread-safety does not extend to things like multiple threads using the same SSL object at the same time.

    I don't see such code for multithreading support in libnavajo. Before i spend any time on fixing this, i would like to make sure we agree on that fact.

    regards Julien

    opened by jcourtat 1
Phorklift is an HTTP server and proxy daemon, with clear, powerful and dynamic configuration.

Phorklift is an HTTP server and proxy daemon, with clear, powerful and dynamic configuration.

null 43 Mar 1, 2022
A collection of C++ HTTP libraries including an easy to use HTTP server.

Proxygen: Facebook's C++ HTTP Libraries This project comprises the core C++ HTTP abstractions used at Facebook. Internally, it is used as the basis fo

Facebook 7.5k Jun 25, 2022
Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services.

Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services. The project is unique among realtime push solutions in that it is designed to address the needs of API creators. Pushpin is transparent to clients and integrates easily into an API stack.

Fanout 3.1k Jun 22, 2022
Gromox - Groupware server backend with MAPI/HTTP, RPC/HTTP, IMAP, POP3 and PHP-MAPI support for grommunio

Gromox is the central groupware server component of grommunio. It is capable of serving as a replacement for Microsoft Exchange and compatibles. Conne

grommunio 119 Jun 27, 2022
DNS and Target HTTP History Local Storage and Search

dooked DNS and Target HTTP History Local Storage and Search Installation Download Boost Library from the official website Extract the library into any

Michael Skelton 58 Jun 16, 2022
The Telegram Bot API provides an HTTP API for creating Telegram Bots.

The Telegram Bot API provides an HTTP API for creating Telegram Bots.

Telegram Library 1.6k Jun 25, 2022
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Cesanta Software 8.5k Jun 29, 2022
A project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server.

PS4 Server 9.00 This is a project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server. this is fo

null 13 Jun 7, 2022
Realtime Client/Server app for Linux allowing joystick (and other HID) data to be transferred over a local network

netstick What is it? Netstick enables HID devices to be remotely connected between a "client" and "server" over a network connection. It allows the ke

null 27 Jun 2, 2022
A local DNS server to obtain the fastest website IP for the best Internet experience

A local DNS server to obtain the fastest website IP for the best Internet experience

Nick Peng 5k Jun 26, 2022
Dohd is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP)

dohd Dohd (pron. doh-dee) is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP). Fe

Dyne.org 13 Mar 28, 2022
tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)

PicoHTTPParser Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase, Shigeo Mitsunari PicoHTTPParser is a tiny, primitive, fast HTTP r

H2O 1.5k Jun 22, 2022
cuehttp is a modern c++ middleware framework for http(http/https)/websocket(ws/wss).

cuehttp 简介 cuehttp是一个使用Modern C++(C++17)编写的跨平台、高性能、易用的HTTP/WebSocket框架。基于中间件模式可以方便、高效、优雅的增加功能。cuehttp基于boost.asio开发,使用picohttpparser进行HTTP协议解析。内部依赖了nl

xcyl 25 Jun 21, 2022
Neon - neon - an HTTP/1.1 and WebDAV client library with a C API

neon neon is an HTTP and WebDAV client library, with a C language API. Mailing list: [email protected] || Web site: https://notroj.github.io/n

Joe Orton 67 Jun 22, 2022
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

What Is RESTinio? RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO

Stiffstream 863 Jun 23, 2022
A C++ header-only HTTP/HTTPS server and client library

cpp-httplib A C++11 single-file header-only cross platform HTTP/HTTPS library. It's extremely easy to setup. Just include the httplib.h file in your c

null 7.2k Jun 24, 2022
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 848 Jun 26, 2022
C++ library for creating an embedded Rest HTTP server (and more)

The libhttpserver reference manual Tl;dr libhttpserver is a C++ library for building high performance RESTful web servers. libhttpserver is built upon

Sebastiano Merlino 660 Jun 20, 2022
cherry: A Minimal HTTP Server

cherry: A Minimal HTTP Server Inspired by the Capriccio project and the Zaver HTTP server, cherry started out as an experimental project trying to inc

Zee 22 Feb 21, 2022