#include <HttpServer.h>
Public Member Functions | |
HttpServer () | |
HttpServer (const HttpServerSettings &settings) | |
void | configure (const HttpServerSettings &settings) |
Allows changing the server configuration. More... | |
void | setBodyParser (const String &contentType, HttpBodyParserDelegate parser) |
Allows content-type specific parsing of the body based on content-type. More... | |
void | setBodyParser (MimeType mimeType, HttpBodyParserDelegate parser) |
Allows content-type specific parsing of the body based on content-type. More... | |
void | addPath (String path, const HttpPathDelegate &callback) |
void | addPath (const String &path, const HttpResourceDelegate &onRequestComplete) |
void | addPath (const String &path, HttpResource *resource) |
void | setDefaultHandler (const HttpPathDelegate &callback) |
void | setDefaultResource (HttpResource *resource) |
virtual bool | listen (int port, bool useSsl=false) |
void | setKeepAlive (uint16_t seconds) |
void | shutdown () |
const Vector< TcpConnection * > & | getConnections () const |
virtual bool | connect (const String &server, int port, bool useSsl=false) |
virtual bool | connect (IpAddress addr, uint16_t port, bool useSsl=false) |
virtual void | close () |
int | writeString (const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
int | writeString (const String &data, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
virtual int | write (const char *data, int len, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
Base write operation. More... | |
int | write (IDataSourceStream *stream) |
uint16_t | getAvailableWriteSize () |
void | flush () |
void | setTimeOut (uint16_t waitTimeOut) |
IpAddress | getRemoteIp () const |
uint16_t | getRemotePort () const |
void | setDestroyedDelegate (TcpConnectionDestroyedDelegate destroyedDelegate) |
Sets a callback to be called when the object instance is destroyed. More... | |
void | setSslInitHandler (Ssl::Session::InitDelegate handler) |
Set the SSL session initialisation callback. More... | |
bool | setSslConnection (Ssl::Connection *connection) |
Ssl::Session * | getSsl () |
Get a pointer to the current SSL session object. More... | |
Public Attributes | |
HttpResourceTree | paths |
Maps paths to resources which deal with incoming requests. More... | |
uint16_t | activeClients = 0 |
Protected Member Functions | |
TcpConnection * | createClient (tcp_pcb *clientTcp) override |
virtual err_t | onAccept (tcp_pcb *clientTcp, err_t err) |
virtual void | onClient (TcpClient *client) |
virtual bool | onClientReceive (TcpClient &client, char *data, int size) |
virtual void | onClientComplete (TcpClient &client, bool successful) |
virtual void | onClientDestroy (TcpConnection &connection) |
void | initialize (tcp_pcb *pcb) |
bool | internalConnect (IpAddress addr, uint16_t port) |
bool | sslCreateSession () |
virtual void | sslInitSession (Ssl::Session &session) |
Override in inherited classes to perform custom session initialisation. More... | |
virtual err_t | onConnected (err_t err) |
virtual err_t | onReceive (pbuf *buf) |
virtual err_t | onSent (uint16_t len) |
virtual err_t | onPoll () |
virtual void | onError (err_t err) |
virtual void | onReadyToSendData (TcpConnectionEvent sourceEvent) |
void | trySend (TcpConnectionEvent event) |
err_t | internalOnConnected (err_t err) |
err_t | internalOnReceive (pbuf *p, err_t err) |
err_t | internalOnSent (uint16_t len) |
err_t | internalOnPoll () |
void | internalOnError (err_t err) |
void | internalOnDnsResponse (const char *name, LWIP_IP_ADDR_T *ipaddr, int port) |
Protected Attributes | |
size_t | minHeapSize = 16384 |
uint16_t | maxConnections = 0 |
By default, don't limit connection count. More... | |
bool | active = true |
Vector< TcpConnection * > | connections |
tcp_pcb * | tcp = nullptr |
uint16_t | sleep = 0 |
uint16_t | timeOut = USHRT_MAX |
By default a TCP connection does not have a time out. More... | |
bool | canSend = true |
bool | autoSelfDestruct = true |
Ssl::Session * | ssl = nullptr |
Ssl::Session::InitDelegate | sslInit |
bool | useSsl = false |
Constructor & Destructor Documentation
◆ HttpServer() [1/2]
|
inline |
◆ HttpServer() [2/2]
|
inline |
Member Function Documentation
◆ addPath() [1/3]
|
inline |
- Deprecated:
- Use
paths.set()
instead
◆ addPath() [2/3]
|
inline |
- Deprecated:
- Use
paths.set()
instead
◆ addPath() [3/3]
|
inline |
- Deprecated:
- Use
paths.set()
instead
◆ close()
|
virtualinherited |
Reimplemented in TcpClient.
◆ configure()
void HttpServer::configure | ( | const HttpServerSettings & | settings | ) |
Allows changing the server configuration.
◆ connect() [1/2]
|
virtualinherited |
Reimplemented in TcpClient, and HttpClientConnection.
◆ connect() [2/2]
|
virtualinherited |
Reimplemented in TcpClient.
◆ createClient()
|
overrideprotectedvirtual |
Reimplemented from TcpServer.
◆ flush()
|
inherited |
◆ getAvailableWriteSize()
|
inlineinherited |
◆ getConnections()
|
inlineinherited |
◆ getRemoteIp()
|
inlineinherited |
◆ getRemotePort()
|
inlineinherited |
◆ getSsl()
|
inlineinherited |
Get a pointer to the current SSL session object.
Note that this is typically used so we can query properties of an established session. If you need to change session parameters this must be done via setSslInitHandler
.
◆ initialize()
|
protectedinherited |
◆ internalConnect()
◆ internalOnConnected()
|
protectedinherited |
◆ internalOnDnsResponse()
|
protectedinherited |
◆ internalOnError()
|
protectedinherited |
◆ internalOnPoll()
|
protectedinherited |
◆ internalOnReceive()
|
protectedinherited |
◆ internalOnSent()
|
protectedinherited |
◆ listen()
◆ onAccept()
|
protectedvirtualinherited |
◆ onClient()
|
protectedvirtualinherited |
◆ onClientComplete()
|
protectedvirtualinherited |
◆ onClientDestroy()
|
protectedvirtualinherited |
◆ onClientReceive()
|
protectedvirtualinherited |
◆ onConnected()
|
protectedvirtualinherited |
Reimplemented in TcpClient, and FtpDataStream.
◆ onError()
|
protectedvirtualinherited |
Reimplemented in HttpConnection, and TcpClient.
◆ onPoll()
|
protectedvirtualinherited |
◆ onReadyToSendData()
|
protectedvirtualinherited |
Reimplemented in MqttClient, SmtpClient, TcpClient, HttpServerConnection, HttpClientConnection, FtpDataStream, and FtpServerConnection.
◆ onReceive()
|
protectedvirtualinherited |
Reimplemented in SmtpClient, TcpClient, FtpServerConnection, and FtpDataStore.
◆ onSent()
|
protectedvirtualinherited |
Reimplemented in TcpClient, FtpServerConnection, and FtpDataStream.
◆ setBodyParser() [1/2]
|
inline |
Allows content-type specific parsing of the body based on content-type.
- Parameters
-
contentType Can be full content-type like 'application/json', or 'application/*' or '*'. If there is exact match for the content-type wildcard content-types will not be used. There can be only one catch-all '*' body parser and that will be the last registered parser
◆ setBodyParser() [2/2]
|
inline |
Allows content-type specific parsing of the body based on content-type.
- Parameters
-
mimeType parser
◆ setDefaultHandler()
|
inline |
- Deprecated:
- Use
paths.setDefault()
instead
◆ setDefaultResource()
|
inline |
- Deprecated:
- Use
paths.setDefault()
instead
◆ setDestroyedDelegate()
|
inlineinherited |
Sets a callback to be called when the object instance is destroyed.
- Parameters
-
destroyedDelegate
◆ setKeepAlive()
|
inherited |
◆ setSslConnection()
|
inlineinherited |
◆ setSslInitHandler()
|
inlineinherited |
Set the SSL session initialisation callback.
- Parameters
-
handler
◆ setTimeOut()
|
inherited |
◆ shutdown()
|
inherited |
◆ sslCreateSession()
|
protectedinherited |
◆ sslInitSession()
|
inlineprotectedvirtualinherited |
Override in inherited classes to perform custom session initialisation.
Called when TCP connection is established before initiating handshake.
Reimplemented in HttpClientConnection.
◆ trySend()
|
inlineprotectedinherited |
◆ write() [1/2]
|
virtualinherited |
Base write operation.
- Parameters
-
data len apiflags TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return values
-
int -1 on error
Reimplemented in FtpDataStream.
◆ write() [2/2]
|
inherited |
◆ writeString() [1/2]
|
inlineinherited |
◆ writeString() [2/2]
|
inlineinherited |
Member Data Documentation
◆ active
|
protectedinherited |
◆ activeClients
|
inherited |
◆ autoSelfDestruct
|
protectedinherited |
◆ canSend
|
protectedinherited |
◆ connections
|
protectedinherited |
◆ maxConnections
|
protectedinherited |
By default, don't limit connection count.
◆ minHeapSize
|
protectedinherited |
◆ paths
HttpResourceTree HttpServer::paths |
Maps paths to resources which deal with incoming requests.
◆ sleep
|
protectedinherited |
◆ ssl
|
protectedinherited |
◆ sslInit
|
protectedinherited |
◆ tcp
|
protectedinherited |
◆ timeOut
|
protectedinherited |
By default a TCP connection does not have a time out.
◆ useSsl
|
protectedinherited |
The documentation for this class was generated from the following file: