No description
Find a file
2017-11-19 18:03:28 +01:00
tests Added Request::remote_endpoint tests to io_test 2017-11-15 07:40:02 +01:00
web Added default GET-example 2014-07-11 12:43:58 +02:00
.clang-format Added .clang-format file and applied style to source files 2017-06-26 15:23:29 +02:00
.gitignore Added status_code_test to .gitignore 2017-09-08 15:05:15 +02:00
.travis.yml Modernised all CMakeLists.txt files, and made it easier to use Simple-Web-Server as a sub-project 2017-11-07 11:45:17 +01:00
client_http.hpp Fixes #173: added server support for chunked transfer encoded requests 2017-11-19 18:03:28 +01:00
client_https.hpp Removed unnecessary cstddef includes 2017-09-30 12:08:53 +02:00
CMakeLists.txt Added MSVC support to cmake files (not tested, but hopefully it works). Some tests are disabled due to lacking MSVC options. 2017-11-14 19:44:40 +01:00
crypto.hpp Updated TODO comment in crypto.hpp 2017-11-08 09:56:46 +01:00
http_examples.cpp Applied newer clang-format on http(s)_examples 2017-11-18 09:58:48 +01:00
https_examples.cpp Applied newer clang-format on http(s)_examples 2017-11-18 09:58:48 +01:00
LICENSE Updated copyright year in LICENSE 2016-07-01 09:26:44 +02:00
README.md Updated README.md to include standalone asio 2017-06-28 08:27:52 +02:00
server_http.hpp Fixes #173: added server support for chunked transfer encoded requests 2017-11-19 18:03:28 +01:00
server_https.hpp Fixes issue mentioned in #164: remote endpoint address and port was not correctly set. Request::remote_endpoint_address and Request::remote_endpoint_port are now functions instead of variables in order to reduce unnecessary instructions. 2017-11-05 18:48:21 +01:00
status_code.hpp Optimised the status_code-functions 2017-11-10 08:22:33 +01:00
utility.hpp HttpHeader::FieldValue::SemicolonSeparated renamed to HttpHeader::FieldValue::SemicolonSeparatedAttributes, and cleanup of HttpHeader::FieldValue::SemicolonSeparatedAttributes::parse, attribute values are now also percent-decoded 2017-11-08 11:30:21 +01:00

Simple-Web-Server Build Status

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Asio (both Boost.Asio and standalone Asio can be used). 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.Asio or standalone Asio
  • Boost is required to compile the examples
  • 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/