All Projects → RipcordSoftware → libhttpserver

RipcordSoftware / libhttpserver

Licence: MIT license
A simple, easy to use C++ 11 based HTTP web server

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to libhttpserver

HPX Projects
⚡ High-Performance-Computing with C++
Stars: ✭ 15 (-21.05%)
Mutual labels:  boost
textTinyR
Text Processing for Small or Big Data Files in R
Stars: ✭ 32 (+68.42%)
Mutual labels:  boost
boost-wintls
Native Windows TLS stream wrapper for use with boost::asio
Stars: ✭ 24 (+26.32%)
Mutual labels:  boost
boost
🚀 A collection of type-safe cross-platform packages for building robust server-side and client-side systems.
Stars: ✭ 97 (+410.53%)
Mutual labels:  boost
SierraChartZorroPlugin
A Zorro broker API plugin for Sierra Chart, written in Win32 C++.
Stars: ✭ 22 (+15.79%)
Mutual labels:  boost
lexical cast
General literal text conversions, such as an int represented as a string, or vice versa
Stars: ✭ 23 (+21.05%)
Mutual labels:  boost
boost-reflection
This library provides Java-like Reflection API to C++ language.
Stars: ✭ 16 (-15.79%)
Mutual labels:  boost
axmldec
Stand-alone binary AndroidManifest.xml decoder
Stars: ✭ 151 (+694.74%)
Mutual labels:  boost
cpp-code-snippets
Some useful C++ code snippets
Stars: ✭ 35 (+84.21%)
Mutual labels:  boost
ZeroMQ
🚀 Client/Server & Pub/Sub Examples with ZeroMQ & Boost
Stars: ✭ 33 (+73.68%)
Mutual labels:  boost
Shareaza
Shareaza is a peer-to-peer client for Windows that allows you to download any file-type found on several popular P2P networks.
Stars: ✭ 103 (+442.11%)
Mutual labels:  boost
gtkmm-plplot
a scientific plotting library for Gtkmm leveraging the power of PLplot
Stars: ✭ 59 (+210.53%)
Mutual labels:  boost
type index
Runtime/Compile time copyable type info.
Stars: ✭ 20 (+5.26%)
Mutual labels:  boost
HyperGraphLib
C++ Hypergraph modelling Library using Boost and OpenMP with some algorithms, including isomorphism using Gecode.
Stars: ✭ 19 (+0%)
Mutual labels:  boost
Boost-for-Android-Prebuilt
boost for android
Stars: ✭ 58 (+205.26%)
Mutual labels:  boost
developkit set
2021年最新总结,值得推荐的c/c++开源框架与库。持续更新中。
Stars: ✭ 654 (+3342.11%)
Mutual labels:  boost
Boost.toml
header-only C++(98|11|14|17) TOML v0.5.0 parser/encoder depending on Boost
Stars: ✭ 26 (+36.84%)
Mutual labels:  boost
Boost-Python-Examples
Implementation of C++ Boost Python Examples, With python3.5+ support
Stars: ✭ 34 (+78.95%)
Mutual labels:  boost
build-scripts
Utility scripts for building of 3rd-party libraries
Stars: ✭ 33 (+73.68%)
Mutual labels:  boost
boost
Boost Maven and Gradle plugins for MicroProfile development
Stars: ✭ 27 (+42.11%)
Mutual labels:  boost

Build Status Coverage Status License

libhttpserver

An HTTP web server implemented in C++ 11 and based on Boost::Asio.

Features:

  • Handles HTTP 1.0 and 1.1 clients
  • Handles chunked POST/PUT requests
  • Supports chunked responses
  • Supports GZIP responses
  • Low memory overhead streaming response API with helpers for strings and files
  • Utilizes HTTP keep-alive up to a configured request limit

Build Status

OS Architecture Status
Debian 8.6 i386 debian-8.6-i386
Debian 8.6 amd64 debian-8.6-amd64
Ubuntu 14.04 amd64 ubutu-14.04-amd64
Ubuntu 16.04 amd64 ubuntu-16.04-amd64
CentOS 6.8 amd64 centos-6.8-amd64
CentOS 7.3 amd64 centos-7.3-amd64
Fedora 25 amd64 fedora-25-amd64
FreeBSD 11 amd64 freebsd-11-amd64

Examples

The simplist possible web server:

#include "libhttpserver.h"
using rs::httpserver;

int main() {
  auto server = HttpServer::Create("0.0.0.0", 1080);
  auto func = [](socket_ptr socket, request_ptr request, response_ptr response) {
    response->setContentType("text/html").Send("<html><body><h1>Hello from libhttpserver</h1></body></html>");
  };
  server->Start(func);
}

Respond from the filesystem:

#include "libhttpserver.h"
using rs::httpserver;

int main() {
  // the server will listen on all IPs on port 1080
  auto server = HttpServer::Create("0.0.0.0", 1080);
  
  // a lambda function which handles the request
  auto func = [](socket_ptr socket, request_ptr request, response_ptr response) {
    // get the request uri
    auto uri = request->getUri();
    
    if (uri == "/") {
      // the uri was just /, redirect to /index.html
      response->Redirect("/index.html");
    } else {
      // use the uri file extension to determine the content type
      auto contentType = MimeTypes::GetType(uri);
      
      // we only respond if we got a content type
      if (contentType) {
        // the content files are in the www sub-directory
        uri = "www" + uri;
        
        // open a stream on the file
        FileStream stream(uri);
        if (stream) {
          // respond with the contents of the file
          response->setContentType(contentType.get()).Send(stream);
        }
    }
  };
  
  // starts the server and blocks
  server->Start(func);
}

The example above assumes the web content is in the sub-directory www. If the content type could not be found or the file does not exist then the server will respond with a 404 Not Found.

You can extend the Content/MIME type mapping as follows:

rs::httpserver::MimeTypes::AddType(".bz2", "application/x-bzip2", false);

See src/httpserver/main.cpp for a working file based web server impl with last-modified/etag support.

Building

You will need:

  • GCC 4.8 or clang 3.5 or higher
  • GNU Make
  • Boost 1.53 or higher
  • ZLib 1.2.7 or higher
  • Doxygen (for the docs)

To build the binaries on Linux:

 $ make

To build and run the tests:

 $ make test

To build the documentation:

 $ make docs

On OSX or BSD add CC=clang CXX=clang++ to the command line, e.g. make CC=clang CXX=clang++.

Linking

Apart from including the libhttpserver.h you will need to configure your application to link against the following libraries:

  • libhttpserver (!)
  • boost_filesystem
  • boost_thread
  • boost_date_time
  • boost_system
  • zlib
  • pthreads
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].