join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicHttpSecureServer< Protocol > Class Template Reference

basic HTTPS server. More...

#include <httpserver.hpp>

Inheritance diagram for join::BasicHttpSecureServer< Protocol >:
Collaboration diagram for join::BasicHttpSecureServer< Protocol >:

Public Types

using Worker = BasicHttpWorker <Protocol>
 
using Content = BasicHttpContent <Protocol>
 
using Handler = typename Content::Handler
 
using Access = typename Content::Access
 
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using Acceptor = typename Protocol::Acceptor
 
- Public Types inherited from join::BasicHttpServer< Protocol >
using Worker = BasicHttpWorker <Protocol>
 
using Content = BasicHttpContent <Protocol>
 
using Handler = typename Content::Handler
 
using Access = typename Content::Access
 
using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using Acceptor = typename Protocol::Acceptor
 

Public Member Functions

 BasicHttpSecureServer (size_t workers=std::thread::hardware_concurrency())
 create the HTTPS server instance.
 
 BasicHttpSecureServer (const BasicHttpSecureServer &other)=delete
 create instance by copy.
 
BasicHttpSecureServeroperator= (const BasicHttpSecureServer &other)=delete
 assign instance by copy.
 
 BasicHttpSecureServer (BasicHttpSecureServer &&other)=delete
 create instance by move.
 
BasicHttpSecureServeroperator= (BasicHttpSecureServer &&other)=delete
 assign instance by move.
 
virtual ~BasicHttpSecureServer ()=default
 destroy the HTTPS server.
 
Socket accept () const override
 accept new connection and fill in the client object with connection parameters.
 
int setCertificate (const std::string &cert, const std::string &key="")
 set the certificate and the private key.
 
int setCaCertificate (const std::string &caFile)
 Set the location of the trusted CA certificate.
 
void setVerify (bool verify, int depth=-1)
 Enable/Disable the verification of the peer certificate.
 
int setCipher (const std::string &cipher)
 set the cipher list (TLSv1.2 and below).
 
int setCipher_1_3 (const std::string &cipher)
 set the cipher list (TLSv1.3).
 
virtual std::string scheme () const override
 get scheme.
 
- Public Member Functions inherited from join::BasicHttpServer< Protocol >
 BasicHttpServer (size_t workers=std::thread::hardware_concurrency())
 create the HTTP server instance.
 
 BasicHttpServer (const BasicHttpServer &other)=delete
 create instance by copy.
 
BasicHttpServeroperator= (const BasicHttpServer &other)=delete
 assign instance by copy.
 
 BasicHttpServer (BasicHttpServer &&other)=delete
 create instance by move.
 
BasicHttpServeroperator= (BasicHttpServer &&other)=delete
 assign instance by move.
 
virtual ~BasicHttpServer ()
 destroy the HTTP server.
 
int create (const Endpoint &endpoint) noexcept
 create server.
 
void close () noexcept
 close server.
 
void baseLocation (const std::string &path)
 set file base location.
 
const std::string & baseLocation () const
 get file base location.
 
void keepAlive (std::chrono::seconds timeout, int max=1000)
 set HTTP keep alive.
 
std::chrono::seconds keepAliveTimeout () const
 get HTTP keep alive timeout.
 
int keepAliveMax () const
 get HTTP keep alive max.
 
ContentaddDocumentRoot (const std::string &dir, const std::string &name, const Access &access=nullptr)
 map an URL to filesystem adding URL path to the base location.
 
ContentaddAlias (const std::string &dir, const std::string &name, const std::string &alias, const Access &access=nullptr)
 map an URL to filesystem replacing URL path by the specified path.
 
ContentaddExecute (const HttpMethod methods, const std::string &dir, const std::string &name, const Handler &handler, const Access &access=nullptr)
 map an URL to a callback.
 
ContentaddRedirect (const std::string &dir, const std::string &name, const std::string &location, const Access &access=nullptr)
 map an URL to a redirection.
 

Public Attributes

friend Worker
 friendship with worker.
 

Additional Inherited Members

- Protected Member Functions inherited from join::BasicHttpServer< Protocol >
ContentfindContent (HttpMethod method, const std::string &path) const
 find content.
 
- Protected Attributes inherited from join::BasicHttpServer< Protocol >
Acceptor _acceptor
 acceptor.
 
int _event = -1
 gracefully stop all workers.
 
size_t _nworkers
 number of workers.
 
std::vector< std::unique_ptr< Worker > > _workers
 workers.
 
Mutex _mutex
 accept protection mutex.
 
std::vector< std::unique_ptr< Content > > _contents
 contents.
 
std::string _baseLocation
 base location.
 
std::chrono::seconds _keepTimeout
 keep alive timeout.
 
int _keepMax = 1000
 keep alive max.
 
Cache _cache
 file cache.
 
friend Worker
 friendship with worker.
 

Detailed Description

template<class Protocol>
class join::BasicHttpSecureServer< Protocol >

basic HTTPS server.

Member Typedef Documentation

◆ Acceptor

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Acceptor = typename Protocol::Acceptor

◆ Access

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Access = typename Content::Access

◆ Content

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Content = BasicHttpContent <Protocol>

◆ Endpoint

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Endpoint = typename Protocol::Endpoint

◆ Handler

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Handler = typename Content::Handler

◆ Socket

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Socket = typename Protocol::Socket

◆ Worker

template<class Protocol >
using join::BasicHttpSecureServer< Protocol >::Worker = BasicHttpWorker <Protocol>

Constructor & Destructor Documentation

◆ BasicHttpSecureServer() [1/3]

template<class Protocol >
join::BasicHttpSecureServer< Protocol >::BasicHttpSecureServer ( size_t workers = std::thread::hardware_concurrency ())
inline

create the HTTPS server instance.

Parameters
workersnumber of worker threads.

◆ BasicHttpSecureServer() [2/3]

template<class Protocol >
join::BasicHttpSecureServer< Protocol >::BasicHttpSecureServer ( const BasicHttpSecureServer< Protocol > & other)
delete

create instance by copy.

Parameters
otherobject to copy.

◆ BasicHttpSecureServer() [3/3]

template<class Protocol >
join::BasicHttpSecureServer< Protocol >::BasicHttpSecureServer ( BasicHttpSecureServer< Protocol > && other)
delete

create instance by move.

Parameters
otherobject to move.

◆ ~BasicHttpSecureServer()

template<class Protocol >
virtual join::BasicHttpSecureServer< Protocol >::~BasicHttpSecureServer ( )
virtualdefault

destroy the HTTPS server.

Member Function Documentation

◆ accept()

template<class Protocol >
Socket join::BasicHttpSecureServer< Protocol >::accept ( ) const
inlineoverridevirtual

accept new connection and fill in the client object with connection parameters.

Returns
the accepted client socket object.

Reimplemented from join::BasicHttpServer< Protocol >.

◆ operator=() [1/2]

template<class Protocol >
BasicHttpSecureServer & join::BasicHttpSecureServer< Protocol >::operator= ( BasicHttpSecureServer< Protocol > && other)
delete

assign instance by move.

Parameters
otherobject to move.
Returns
a reference of the current object.

◆ operator=() [2/2]

template<class Protocol >
BasicHttpSecureServer & join::BasicHttpSecureServer< Protocol >::operator= ( const BasicHttpSecureServer< Protocol > & other)
delete

assign instance by copy.

Parameters
otherobject to copy.
Returns
a reference of the current object.

◆ scheme()

template<class Protocol >
virtual std::string join::BasicHttpSecureServer< Protocol >::scheme ( ) const
inlineoverridevirtual

get scheme.

Returns
htpp or https.

Reimplemented from join::BasicHttpServer< Protocol >.

◆ setCaCertificate()

template<class Protocol >
int join::BasicHttpSecureServer< Protocol >::setCaCertificate ( const std::string & caFile)
inline

Set the location of the trusted CA certificate.

Parameters
caFilepath of the trusted CA certificate file.
Returns
0 on success, -1 on failure.

◆ setCertificate()

template<class Protocol >
int join::BasicHttpSecureServer< Protocol >::setCertificate ( const std::string & cert,
const std::string & key = "" )
inline

set the certificate and the private key.

Parameters
certcertificate path.
keyprivate key path.
Returns
0 on success, -1 on failure.

◆ setCipher()

template<class Protocol >
int join::BasicHttpSecureServer< Protocol >::setCipher ( const std::string & cipher)
inline

set the cipher list (TLSv1.2 and below).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setCipher_1_3()

template<class Protocol >
int join::BasicHttpSecureServer< Protocol >::setCipher_1_3 ( const std::string & cipher)
inline

set the cipher list (TLSv1.3).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setVerify()

template<class Protocol >
void join::BasicHttpSecureServer< Protocol >::setVerify ( bool verify,
int depth = -1 )
inline

Enable/Disable the verification of the peer certificate.

Parameters
verifyEnable peer verification if set to true, false otherwise.
depthThe maximum certificate verification depth (default: no limit).

Member Data Documentation

◆ Worker

template<class Protocol >
friend join::BasicHttpSecureServer< Protocol >::Worker

friendship with worker.


The documentation for this class was generated from the following files: