No description
Find a file
Ole Christian Eidheim 25cf95276d Merge pull request #27 from DraconPern/master
fixed vs2012 compile
2015-11-28 11:08:46 +01:00
test A few minor changes to #22. 2015-10-24 16:58:18 +02:00
web Added default GET-example 2014-07-11 12:43:58 +02:00
.gitignore Added .gitignore. 2015-11-26 14:31:20 +01:00
client_http.hpp Improved Client::parse_response_header, and simplified endpoint code in Server::start. 2015-11-26 14:29:43 +01:00
client_https.hpp Added custom response stream and possibility to flush response to clients synchronously and asynchronously. Various speed ups, including reduced use of regex and preprocessing of regex objects. boost::asio::ip::tcp::no_delay is now turned on for both Client and Server. Note: Not backward compatible with earlier versions. 2015-02-20 11:14:39 +01:00
CMakeLists.txt Corrected OpenSSL_FOUND to OPENSSL_FOUND. 2015-11-15 21:30:05 +01:00
http_examples.cpp Slight cleanup and added convenience function to retrieve Request::content string. 2015-09-19 13:01:40 +02:00
https_examples.cpp Update https_examples.cpp 2015-09-21 14:51:49 +02:00
LICENSE Update LICENSE 2014-07-05 20:05:52 +02:00
README.md Renamed HttpServer:: to Server:: in README.md. 2015-11-20 10:00:02 +01:00
server_http.hpp fixed vs2012 compile 2015-11-27 14:43:38 -06:00
server_https.hpp Added custom response stream and possibility to flush response to clients synchronously and asynchronously. Various speed ups, including reduced use of regex and preprocessing of regex objects. boost::asio::ip::tcp::no_delay is now turned on for both Client and Server. Note: Not backward compatible with earlier versions. 2015-02-20 11:14:39 +01:00

Simple-Web-Server

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 also https://github.com/eidheim/Simple-WebSocket-Server for an easy way to make WebSocket/WebSocket Secure endpoints in C++.

Features

  • Thread pool
  • 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
  • Possibility to flush response to clients synchronously (Server::Response::flush).

###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.

The default_resource includes example use of Server::Response::flush.

Dependencies

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

Compile and run

Compile with a C++11 compliant compiler:

cmake .
make

HTTP

Run the server and client examples: ./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: ./https_examples

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