No description
Find a file
2019-07-10 16:07:57 +02:00
tests Cleanup of include guards 2019-06-25 11:56:21 +02: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 c++17 string_view support 2018-02-27 09:54:51 -05:00
.gitlab-ci.yml Migrated to GitLab 2018-06-09 19:29:33 +02:00
asio_compatibility.hpp Cleanup of include guards 2019-06-25 11:56:21 +02:00
client_http.hpp Fixes #269 : Replaced ssize_t with std::streamsize 2019-07-03 20:28:58 +02:00
client_https.hpp Cleanup of include guards 2019-06-25 11:56:21 +02:00
CMakeLists.txt Add option to build without OpenSSL 2019-07-10 16:07:57 +02:00
crypto.hpp Related to #150: added LIBRESSL_VERSION_NUMBER check to BIO_new_mem_buf in order to support libressl 2018-08-26 22:30:28 +02:00
http_examples.cpp Moved SimpleWeb::string_view to utility.hpp, and made use of string_view in Server::Response::write 2018-07-12 08:43:07 +02:00
https_examples.cpp Moved SimpleWeb::string_view to utility.hpp, and made use of string_view in Server::Response::write 2018-07-12 08:43:07 +02:00
LICENSE Updated license year 2018-05-27 11:57:39 +02:00
mutex.hpp Made use of clang's Thread Safety Analysis 2019-06-25 11:29:36 +02:00
README.md Updated feature section 2019-06-24 08:41:37 +02:00
server_http.hpp Cleanup of include guards 2019-06-25 11:56:21 +02:00
server_https.hpp Cleanup of include guards 2019-06-25 11:56:21 +02:00
status_code.hpp Fixes #261: SimpleWeb::status_code(const std::string &) now only regards the status code number when searching for status code enum, and can also return undefined enums that can be cast to an integer value 2019-04-29 13:30:22 +02:00
utility.hpp Client: added support for non-standard line endings in response status and header 2019-06-24 19:48:11 +02:00

Simple-Web-Server

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://gitlab.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://gitlab.com/cppit/jucipp.

Features

  • Asynchronous request handling
  • Thread pool if needed
  • Platform independent
  • HTTP/1.1 supported, including persistent connections
  • HTTPS supported
  • Chunked transfer encoding and server-sent events
  • Can set timeouts for request/response and content
  • Can set max request/response size
  • Sending outgoing messages is thread safe
  • Client creates necessary connections and perform reconnects when needed

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/