A library for embedding HTTP or HTTPS, IPV6 and IPV4 servers in C++ applications.
via-httplib
is an asynchronous C++ HTTP server built upon boost asio
that
aims to provide a simple, secure and efficient server that complies with the
requirements of rfc7230
wherever possible.
The server is via::http_server
, a class template requiring a
SocketAdaptor
to instantiate it:
- a
tcp_adaptor
for a plain HTTP server - an
ssl_tcp_adaptor
for an HTTPS server
Whether the server accepts IPV6 and IPV4 connections or just IPV4 connections depends upon how the port is configured:
- IPV6, (the default) the server accepts both IPV6 and IPV4 connections
- IPV4 only, the server only accepts IPV4 connections
The server can be configured to pass HTTP message bodies in different types of containers, e.g.:
std::vector<char>
(the default) for handing binary data, e.g. images, files, etc.std::string
for handing textural data, e.g. HTML, JSON, etc.
Socket Adaptor | Container | Description |
---|---|---|
tcp_adaptor |
std::vector<char> |
An HTTP data server. |
tcp_adaptor |
std::string |
An HTTP text server. |
ssl_tcp_adaptor |
std::vector<char> |
An HTTPS data server. |
ssl_tcp_adaptor |
std::string |
An HTTPS text server. |
The HTTP message bodies can be sent using buffered or unbuffered methods.
The unbuffered methods use "scatter-gather" writes to avoid copying data.
-
A C++11 compiler.
This version requires a complier that supports: lambdas, enum classes, member function delete and std::functional. It's been tested withMSVC 2015
,MSVC 2013
,GCC 4.9.1
andMinGw 4.9.1
. -
The
boost
C++ library, especiallyasio
, see boost. -
For HTTPS, the
OpenSSL
library, see openssl. -
For C++ code documentation, Doxygen, see Doxygen
-
Note: there is currently an issue building
boost
asio
withVisual Studio 2015 Update 2
, see Issue 4
Download the latest tagged version of via-httplib
from
Github
and follow the instructions here: Make.
Or simply build the .cpp files into your application (there are 8 of them).
via-http
lib depends on the boost
libraries.
If boost
is not installed on your machine then download the latest package from
boost and follow the instructions here:
boost getting started.
The boost asio
library (and hence via-httplib
) depends upon the
OpenSSL
library to implement SSL/TLS sockets.
If you require an HTTPS server or client then you'll need to install the
OpenSSL
library as well.
Please note that a plain HTTP server should not require OpenSLL
.
If OpenSLL
is not installed on your machine then you may download the latest stable
package from openssl source and build it.
Note: a binary distribution may be available for your machine,
see: OpenSSL binaries.
Document | Description |
---|---|
Build Guide | How to build the library. |
Server User Guide | How to use the library to create HTTP servers. |
Client User Guide | How to use the library to create HTTP clients. |
Security Guide | How to configure the library securely. |
Design | The library design. |
examples/server | Example HTTP & HTTPS servers. |
examples/client | Example HTTP & HTTPS clients. |
Directory | Contents |
---|---|
via | The via-httplib API classes: http_server, http_connection and http_client. |
examples/server | Example HTTP & HTTPS servers. |
examples/client | Example HTTP & HTTPS clients. |
tests |
A unit tests for the HTTP parsers and encoders. |
docs | The User Guides and design documents. |
docs/html |
Doxygen output directory. Created by running doxygen Doxyfile in the docs directory. |
Thanks to:
- Neil Tisdale for encouraging and inspiring me to create the library
- Louis Nayegon for helping to develop it and recommending GitHub
- Adam Leggett for helping to identify and fix security, efficiency and CMake issues
- Christopher Kohlhoff for the
asio
library, without which, this library wouldn't exist.