No description
Find a file
2019-07-31 21:38:35 +02:00
docs Moved the dependency installation instructions to README.md as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-515909842 2019-07-30 21:02:47 +02:00
paper Updated paper.md based on feedback in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-515900507 2019-07-30 20:39:04 +02:00
tests Added SimpleWeb::Date::to_string to create HTTP date strings 2019-07-31 15:23:50 +02:00
web Added default GET-example 2014-07-11 12:43:58 +02:00
.clang-format Added SimpleWeb::Date::to_string to create HTTP date strings 2019-07-31 15:23:50 +02:00
.gitignore Added more detailed dependency installation instructions as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-515789575 2019-07-29 10:14:34 +02:00
.gitlab-ci.yml Added more detailed dependency installation instructions as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-515789575 2019-07-29 10:14:34 +02:00
asio_compatibility.hpp Cleanup of include guards 2019-06-25 11:56:21 +02:00
client_http.hpp Improved comments on public functions and variables as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-514946444 2019-07-26 09:28:20 +02:00
client_https.hpp Improved comments on public functions and variables as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-514946444 2019-07-26 09:28:20 +02:00
CMakeLists.txt Add option to build without OpenSSL 2019-07-10 16:07:57 +02:00
crypto.hpp Improved comments on public functions and variables as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-514946444 2019-07-26 09:28:20 +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 2019-07-15 15:25:14 +02:00
mutex.hpp Improved comments on public functions and variables as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-514946444 2019-07-26 09:28:20 +02:00
README.md Moved the dependency installation instructions to README.md as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-515909842 2019-07-30 21:02:47 +02:00
server_http.hpp Now only calls asio::socket::remote_endpoint() when needed 2019-07-31 12:31:24 +02:00
server_https.hpp Improved comments on public functions and variables as suggested in https://github.com/openjournals/joss-reviews/issues/1592#issuecomment-514946444 2019-07-26 09:28:20 +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 Optimized Date::to_string for successive calls 2019-07-31 21:38:35 +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. Particularly, the JSON-POST (using Boost.PropertyTree) and the GET /match/[number] examples might be relevant.

Documentation is also available, generated from the master branch.

Dependencies

  • Boost.Asio or standalone Asio
  • Boost is required to compile the examples
  • For HTTPS: OpenSSL libraries

Installation instructions for the dependencies needed to compile the examples on a selection of platforms can be seen below. Default build with Boost.Asio is assumed. Turn on CMake option USE_STANDALONE_ASIO to instead use standalone Asio.

Debian based distributions

sudo apt-get install libssl-dev libboost-filesystem-dev libboost-thread-dev

Arch Linux based distributions

sudo pacman -S boost

MacOS

brew install openssl boost

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.

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

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

Contributing

Contributions are welcome, either by creating an issue or a merge request. However, before you create a new issue or merge request, please search for previous similar issues or requests. A response will normally be given within a few days.