PL::HttpServer class
-
class HttpServer : public PL::NetworkServer
HTTP/HTTPS server class.
Public Functions
Creates an HTTP server with shared transaction buffer.
- Parameters:
uriBuffer – URI buffer
headerBuffer – header buffer
-
HttpServer(size_t uriBufferSize = defaultUriBufferSize, size_t headerBufferSize = defaultHeaderBufferSize)
Creates an HTTP server and allocate transaction buffer.
- Parameters:
uriBufferSize – URI buffer size
headerBufferSize – header buffer size
Creates an HTTPS server with shared transaction buffer.
- Parameters:
certificate – certificate
privateKey – private key
uriBuffer – URI buffer
headerBuffer – header buffer
-
HttpServer(const char *certificate, const char *privateKey, size_t uriBufferSize = defaultUriBufferSize, size_t headerBufferSize = defaultHeaderBufferSize)
Creates an HTTPS server and allocate transaction buffer.
- Parameters:
certificate – certificate
privateKey – private key
uriBufferSize – URI buffer size
headerBufferSize – header buffer size
-
virtual esp_err_t Lock(TickType_t timeout = portMAX_DELAY) override
Locks the object.
- Parameters:
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
virtual esp_err_t Unlock() override
Unlocks the object.
- Returns:
error code
-
virtual esp_err_t Enable() override
Enables the server.
- Returns:
error code
-
virtual esp_err_t Disable() override
Disables the server.
- Returns:
error code
-
virtual bool IsEnabled() override
Checks if the server is enabled.
- Returns:
true if the server is enabled
-
virtual uint16_t GetPort() override
Gets listening port.
- Returns:
port
-
virtual esp_err_t SetPort(uint16_t port) override
Sets listening port.
- Parameters:
port – port
- Returns:
error code
-
virtual size_t GetMaxNumberOfClients() override
Gets the maximum number of server clients.
- Returns:
number of clients
-
virtual esp_err_t SetMaxNumberOfClients(size_t maxNumberOfClients) override
Sets the maximum number of server clients.
- Parameters:
maxNumberOfClients – number of clients
- Returns:
error code
-
TickType_t GetReadTimeout()
Gets the read operation timeout.
- Returns:
timeout in FreeRTOS ticks
-
esp_err_t SetReadTimeout(TickType_t timeout)
Sets the read operation timeout.
- Parameters:
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
esp_err_t SetTaskParameters(const TaskParameters &taskParameters)
Sets the server task parameters.
- Parameters:
taskParameters – task parameters
- Returns:
error code
-
std::string GetName()
Gets the server name.
- Returns:
name
-
void SetName(const std::string &name)
Sets the server name.
- Parameters:
name – name
Public Members
Public Static Attributes
-
static const std::string defaultHttpName
Default HTTP server name.
-
static const std::string defaultHttpsName
Default HTTPS server name.
-
static const uint16_t defaultHttpPort = 80
Default HTTP port.
-
static const uint16_t defaultHttpsPort = 443
Default HTTPS port.
-
static const int defaultMaxNumberOfClients = 1
Default maximum number of server clients.
-
static const TickType_t defaultReadTimeout = 5000 / portTICK_PERIOD_MS
Default read operation timeout in FreeRTOS ticks.
-
static const TaskParameters defaultTaskParameters
Default server task parameters.
-
static const size_t defaultUriBufferSize = 512
Default URI buffer size.
-
static const size_t defaultHeaderBufferSize = 1024
Default header buffer size.
Protected Functions
-
virtual esp_err_t HandleRequest(HttpServerTransaction &transaction) = 0
Handles the HTTP request.
- Parameters:
clientStream –
request – request
response – response
- Returns:
error code