#include <HttpServerConnection.h>
Public Member Functions | |
HttpServerConnection (tcp_pcb *clientTcp) | |
~HttpServerConnection () | |
void | setResourceTree (HttpResourceTree *resourceTree) |
void | setBodyParsers (const BodyParsers *bodyParsers) |
void | send () |
void | setUpgradeCallback (HttpServerProtocolUpgradeCallback callback) |
HttpRequest * | getRequest () override |
Returns pointer to the current request. More... | |
void | setCloseOnContentError (bool close=true) |
virtual void | reset () |
virtual void | cleanup () |
virtual void | setDefaultParser () |
virtual bool | send (HttpRequest *request) |
bool | send (const char *data, uint16_t len, bool forceCloseAfterSent=false) |
bool | isActive () |
HttpResponse * | getResponse () |
Returns pointer to the current response. More... | |
int | getResponseCode () const |
String | getResponseHeader (const String &headerName, const String &defaultValue=nullptr) const |
HttpHeaders & | getResponseHeaders () |
DateTime | getLastModifiedDate () const |
DateTime | getServerDate () const |
String | getResponseString () |
bool | connect (const String &server, int port, bool useSsl=false) override |
bool | connect (IpAddress addr, uint16_t port, bool useSsl=false) override |
void | close () override |
void | setReceiveDelegate (TcpClientDataDelegate receiveCb=nullptr) |
Set or clear the callback for received data. More... | |
void | setCompleteDelegate (TcpClientCompleteDelegate completeCb=nullptr) |
Set or clear the callback for connection close. More... | |
bool | sendString (const String &data, bool forceCloseAfterSent=false) |
bool | isProcessing () |
TcpClientState | getConnectionState () |
void | setCloseAfterSent (bool ignoreIncomingData=false) |
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 | |
void * | userData = nullptr |
use to pass user data between requests More... | |
Protected Member Functions | |
int | onMessageBegin (http_parser *parser) override |
Called when a new incoming data is beginning to come. More... | |
int | onPath (const Url &path) override |
Called when the URL path is known. More... | |
int | onHeadersComplete (const HttpHeaders &headers) override |
Called when all headers are received. More... | |
int | onBody (const char *at, size_t length) override |
Called when a piece of body data is received. More... | |
int | onMessageComplete (http_parser *parser) override |
Called when the incoming data is complete. More... | |
bool | onProtocolUpgrade (http_parser *parser) override |
Called when the HTTP protocol should be upgraded. More... | |
bool | onHttpError (http_errno error) override |
Called when there was an error. More... | |
void | onReadyToSendData (TcpConnectionEvent sourceEvent) override |
virtual void | sendError (const String &message=nullptr, enum http_status code=HTTP_STATUS_BAD_REQUEST) |
void | resetHeaders () |
Called after all headers have been received and processed. More... | |
virtual void | init (http_parser_type type) |
Initializes the http parser for a specific type of HTTP message. More... | |
virtual int | onStatus (http_parser *parser) |
virtual int | onChunkHeader (http_parser *parser) |
virtual int | onChunkComplete (http_parser *parser) |
virtual bool | onTcpReceive (TcpClient &client, char *data, int size) |
void | onError (err_t err) override |
err_t | onConnected (err_t err) override |
err_t | onReceive (pbuf *buf) override |
err_t | onSent (uint16_t len) override |
virtual void | onFinished (TcpClientState finishState) |
void | pushAsyncPart () |
void | freeStreams () |
void | setBuffer (ReadWriteStream *stream) |
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 | onPoll () |
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 | |
http_parser | parser |
HttpHeaderBuilder | header |
Header construction. More... | |
HttpHeaders | incomingHeaders |
Full set of incoming headers. More... | |
HttpConnectionState | state = eHCS_Ready |
HttpResponse | response |
ReadWriteStream * | buffer = nullptr |
Used internally to buffer arbitrary data via send() methods. More... | |
IDataSourceStream * | stream = nullptr |
The currently active stream being sent. More... | |
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 |
Static Protected Attributes | |
static const http_parser_settings | parserSettings |
Callback table for parser. More... | |
Constructor & Destructor Documentation
◆ HttpServerConnection()
|
inline |
◆ ~HttpServerConnection()
|
inline |
Member Function Documentation
◆ cleanup()
|
inlinevirtualinherited |
Reimplemented in HttpClientConnection.
◆ close()
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ connect() [1/2]
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ connect() [2/2]
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ flush()
|
inherited |
◆ freeStreams()
|
protectedinherited |
◆ getAvailableWriteSize()
|
inlineinherited |
◆ getConnectionState()
|
inlineinherited |
◆ getLastModifiedDate()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->headers.getLastModifiedDate()
instead
◆ getRemoteIp()
|
inlineinherited |
◆ getRemotePort()
|
inlineinherited |
◆ getRequest()
|
inlineoverridevirtual |
◆ getResponse()
|
inlineinherited |
Returns pointer to the current response.
- Return values
-
HttpResponse*
◆ getResponseCode()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->code
instead
◆ getResponseHeader()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->headers[]
instead
◆ getResponseHeaders()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->headers
instead
◆ getResponseString()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->getBody()
instead
◆ getServerDate()
|
inlineinherited |
- Deprecated:
- Use
getResponse()->headers.getServerDate()
instead
◆ 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
.
◆ init()
|
protectedvirtualinherited |
Initializes the http parser for a specific type of HTTP message.
- Parameters
-
type
◆ initialize()
|
protectedinherited |
◆ internalConnect()
◆ internalOnConnected()
|
protectedinherited |
◆ internalOnDnsResponse()
|
protectedinherited |
◆ internalOnError()
|
protectedinherited |
◆ internalOnPoll()
|
protectedinherited |
◆ internalOnReceive()
|
protectedinherited |
◆ internalOnSent()
|
protectedinherited |
◆ isActive()
|
inherited |
◆ isProcessing()
|
inlineinherited |
◆ onBody()
|
overrideprotectedvirtual |
Called when a piece of body data is received.
- Parameters
-
at the data length
- Return values
-
int 0 on success, non-0 on error
Implements HttpConnection.
◆ onChunkComplete()
|
inlineprotectedvirtualinherited |
◆ onChunkHeader()
|
inlineprotectedvirtualinherited |
◆ onConnected()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onError()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onFinished()
|
protectedvirtualinherited |
Reimplemented in MqttClient.
◆ onHeadersComplete()
|
overrideprotectedvirtual |
Called when all headers are received.
- Parameters
-
headers The processed headers
- Return values
-
int 0 on success, non-0 on error
Implements HttpConnection.
◆ onHttpError()
|
overrideprotectedvirtual |
Called when there was an error.
- Parameters
-
error - the error code
- Return values
-
bool - false if the problem is not recoverable, true otherwise
Reimplemented from HttpConnection.
◆ onMessageBegin()
|
overrideprotectedvirtual |
Called when a new incoming data is beginning to come.
- Parameters
-
parser
- Return values
-
int 0 on success, non-0 on error
Implements HttpConnection.
◆ onMessageComplete()
|
overrideprotectedvirtual |
Called when the incoming data is complete.
- Parameters
-
parser
- Return values
-
int 0 on success, non-0 on error
Implements HttpConnection.
◆ onPath()
Called when the URL path is known.
- Parameters
-
uri
- Return values
-
int 0 on success, non-0 on error
Reimplemented from HttpConnection.
◆ onPoll()
|
protectedvirtualinherited |
◆ onProtocolUpgrade()
|
inlineoverrideprotectedvirtual |
Called when the HTTP protocol should be upgraded.
- Parameters
-
parser
- Return values
-
bool true on success
Reimplemented from HttpConnection.
◆ onReadyToSendData()
|
overrideprotectedvirtual |
Reimplemented from TcpConnection.
◆ onReceive()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onSent()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onStatus()
|
inlineprotectedvirtualinherited |
◆ onTcpReceive()
|
protectedvirtualinherited |
◆ pushAsyncPart()
|
protectedinherited |
◆ reset()
|
inlinevirtualinherited |
Reimplemented in HttpClientConnection.
◆ resetHeaders()
|
protectedinherited |
Called after all headers have been received and processed.
◆ send() [1/3]
|
inlinevirtualinherited |
Reimplemented in HttpClientConnection.
◆ send() [2/3]
|
inline |
◆ send() [3/3]
|
inherited |
◆ sendError()
|
protectedvirtual |
◆ sendString()
|
inlineinherited |
◆ setBodyParsers()
|
inline |
◆ setBuffer()
|
protectedinherited |
◆ setCloseAfterSent()
|
inlineinherited |
Schedules the connection to get closed after the data is sent
- Parameters
-
ignoreIncomingData when that flag is set the connection will start ignoring incoming data.
◆ setCloseOnContentError()
|
inline |
◆ setCompleteDelegate()
|
inlineinherited |
Set or clear the callback for connection close.
- Parameters
-
completeCb callback delegate or nullptr
◆ setDefaultParser()
|
virtualinherited |
◆ setDestroyedDelegate()
|
inlineinherited |
Sets a callback to be called when the object instance is destroyed.
- Parameters
-
destroyedDelegate
◆ setReceiveDelegate()
|
inlineinherited |
Set or clear the callback for received data.
- Parameters
-
receiveCb callback delegate or nullptr
◆ setResourceTree()
|
inline |
◆ setSslConnection()
|
inlineinherited |
◆ setSslInitHandler()
|
inlineinherited |
Set the SSL session initialisation callback.
- Parameters
-
handler
◆ setTimeOut()
|
inherited |
◆ setUpgradeCallback()
|
inline |
◆ 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
◆ autoSelfDestruct
|
protectedinherited |
◆ buffer
|
protectedinherited |
Used internally to buffer arbitrary data via send() methods.
◆ canSend
|
protectedinherited |
◆ header
|
protectedinherited |
Header construction.
◆ incomingHeaders
|
protectedinherited |
Full set of incoming headers.
◆ parser
|
protectedinherited |
◆ parserSettings
|
staticprotectedinherited |
Callback table for parser.
◆ response
|
protectedinherited |
◆ sleep
|
protectedinherited |
◆ ssl
|
protectedinherited |
◆ sslInit
|
protectedinherited |
◆ state
|
protectedinherited |
◆ stream
|
protectedinherited |
The currently active stream being sent.
◆ tcp
|
protectedinherited |
◆ timeOut
|
protectedinherited |
By default a TCP connection does not have a time out.
◆ userData
void* HttpServerConnection::userData = nullptr |
use to pass user data between requests
◆ useSsl
|
protectedinherited |
The documentation for this class was generated from the following file: