#include <Pt/Http/Server.h>
HTTP server that listens for incoming connections. More...
Inherits Connectable, and NonCopyable.
Public Member Functions | |
| Server () | |
| Default Constructor. | |
| Server (System::EventLoop &loop) | |
| Construct with event loop. | |
| Server (System::EventLoop &loop, const Net::Endpoint &ep) | |
| Construct with event loop and listen endpoint. | |
| ~Server () | |
| Destructor. | |
| System::EventLoop * | loop () |
| Returns the used event loop. | |
| void | setActive (System::EventLoop &loop) |
| Sets the event loop to use. | |
| std::size_t | timeout () const |
| Returns the timeout in msecs. | |
| void | setTimeout (std::size_t ms) |
| Sets the timeout in msecs. | |
| void | setSecure (Ssl::Context &ctx) |
| Enables HTTPS with ctx. | |
| std::size_t | maxThreads () const |
| Returns the maximum number of server threads. | |
| void | setMaxThreads (std::size_t m) |
| Sets the maximum number of server threads. | |
| std::size_t | keepAliveTimeout () const |
| Returns the keepalive timeout in msecs. | |
| void | setKeepAliveTimeout (std::size_t ms) |
| Sets the keepalive timeout in msecs. | |
| std::size_t | maxRequestSize () const |
| Returns the maximum size of a request in bytes. | |
| void | setMaxRequestSize (std::size_t maxSize) |
| Sets the maximum size of a request in bytes. | |
| void | listen (const Net::Endpoint &ep) |
| Start listening on endpoint. | |
| void | listen (const Net::Endpoint &ep, const Net::TcpServerOptions &opts) |
| Start listening on endpoint. | |
| void | cancel () |
| Cancel all operations. | |
| void | addServlet (Servlet &servlet) |
| Adds a servlet. | |
| void | removeServlet (Servlet &servlet) |
| Removes a servlet. | |
Server binds a local Endpoint and routes each incoming request to the first registered servlet that maps it. The server itself does not provide a resource. Use addServlet() to register a servlet and removeServlet() to unregister it.
Server I/O is asynchronous and requires an EventLoop. Supply the loop when constructing the server or later through setActive(); the server does not take ownership of it. listen() binds an endpoint and replaces an existing binding. cancel() stops accepting connections and cancels pending work.
setSecure() configures the server with a Pt::Ssl::Context for HTTPS connections. The servlet and responder model remains the same.
The server can limit worker threads, request size, idle I/O, and the lifetime of persistent connections.