Skip to content
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
Branch: master
Clone or download
Pull request Compare This branch is 139 commits behind eidheim:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Added .clang-format file and applied style to source files Jun 26, 2017
web
.clang-format Added .clang-format file and applied style to source files Jun 26, 2017
.gitignore Added crypto.hpp for convenient C++ wrappings for commonly used OpenS… Dec 20, 2016
.travis.yml Added all header files to cmake install target. Also added -O3 to one… Jun 26, 2017
CMakeLists.txt Added all header files to cmake install target. Also added -O3 to one… Jun 26, 2017
LICENSE Updated copyright year in LICENSE Jul 1, 2016
README.md Fix broken Markdown headings Apr 18, 2017
client_http.hpp Added .clang-format file and applied style to source files Jun 26, 2017
client_https.hpp Added .clang-format file and applied style to source files Jun 26, 2017
crypto.hpp Added .clang-format file and applied style to source files Jun 26, 2017
http_examples.cpp Added .clang-format file and applied style to source files Jun 26, 2017
https_examples.cpp Added .clang-format file and applied style to source files Jun 26, 2017
server_http.hpp Added .clang-format file and applied style to source files Jun 26, 2017
server_https.hpp Added .clang-format file and applied style to source files Jun 26, 2017
status_code.hpp Added .clang-format file and applied style to source files Jun 26, 2017
utility.hpp Added .clang-format file and applied style to source files Jun 26, 2017

README.md

Simple-Web-Server Build Status

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

See https://github.com/eidheim/Simple-WebSocket-Server for an easy way to make WebSocket/WebSocket Secure endpoints in C++. Also, feel free to check out the new C++ IDE supporting C++11/14/17: https://github.com/cppit/jucipp.

Features

  • Asynchronous request handling
  • Thread pool if needed
  • Platform independent
  • HTTPS support
  • HTTP persistent connection (for HTTP/1.1)
  • Client supports chunked transfer encoding
  • Timeouts, if any of Server::timeout_request and Server::timeout_content are >0 (default: Server::timeout_request=5 seconds, and Server::timeout_content=300 seconds)
  • Simple way to add REST resources using regex for path, and anonymous functions

Usage

See http_examples.cpp or https_examples.cpp for example usage.

See particularly the JSON-POST (using Boost.PropertyTree) and the GET /match/[number] examples, which are most relevant.

Dependencies

  • Boost C++ libraries
  • For HTTPS: OpenSSL libraries

Compile and run

Compile with a C++11 compliant compiler:

mkdir build
cd build
cmake ..
make
cd ..

HTTP

Run the server and client examples: ./build/http_examples

Direct your favorite browser to for instance http://localhost:8080/

HTTPS

Before running the server, an RSA private key (server.key) and an SSL certificate (server.crt) must be created. Follow, for instance, the instructions given here (for a self-signed certificate): http://www.akadia.com/services/ssh_test_certificate.html

Run the server and client examples: ./build/https_examples

Direct your favorite browser to for instance https://localhost:8080/

You can’t perform that action at this time.