Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
|
Public Member Functions | |
bool | connect (const String &host, int port, bool useSsl=false, uint32_t sslOptions=0) override |
bool | send (HttpRequest *request) override |
HttpRequest * | getRequest () override |
Returns pointer to the current request. More... | |
void | reset () override |
virtual void | setDefaultParser () |
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 SMING_DEPRECATED |
String | getResponseHeader (const String &headerName, const String &defaultValue=nullptr) const SMING_DEPRECATED |
HttpHeaders & | getResponseHeaders () SMING_DEPRECATED |
DateTime | getLastModifiedDate () const SMING_DEPRECATED |
DateTime | getServerDate () const SMING_DEPRECATED |
String | getResponseString () SMING_DEPRECATED |
bool | connect (IPAddress addr, uint16_t port, bool useSsl=false, uint32_t sslOptions=0) 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 () |
bool | addSslValidator (SslValidatorCallback callback, void *data=nullptr) |
Allows setting of multiple SSL validators after a successful handshake. More... | |
bool | pinCertificate (const uint8_t *fingerprint, SslFingerprintType type) |
Requires (pins) the remote SSL certificate to match certain fingerprints. More... | |
bool | pinCertificate (SslFingerprints &fingerprints) |
Requires (pins) the remote SSL certificate to match certain fingerprints. More... | |
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 | addSslOptions (uint32_t sslOptions) |
bool | setSslClientKeyCert (const uint8_t *key, int keyLength, const uint8_t *certificate, int certificateLength, const char *keyPassword=nullptr, bool freeAfterHandshake=false) SMING_DEPRECATED |
Sets client private key, certificate and password from memory. More... | |
bool | setSslClientKeyCert (const SslKeyCertPair &clientKeyCert, bool freeAfterHandshake=false) SMING_DEPRECATED |
Sets client private key, certificate and password from memory. More... | |
void | freeSslClientKeyCert () SMING_DEPRECATED |
Frees the memory used for the key and certificate pair. More... | |
bool | setSslKeyCert (const uint8_t *key, int keyLength, const uint8_t *certificate, int certificateLength, const char *keyPassword=nullptr, bool freeAfterHandshake=false) |
Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal. More... | |
bool | setSslKeyCert (const SslKeyCertPair &keyCert, bool freeAfterHandshake=false) |
Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal. More... | |
void | freeSslKeyCert () |
Frees the memory used for the key and certificate pair. More... | |
void | setSsl (SSL *ssl) |
SSL * | getSsl () |
Protected Member Functions | |
int | onMessageBegin (http_parser *parser) override |
Called when a new incoming data is beginning to come. 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... | |
void | onReadyToSendData (TcpConnectionEvent sourceEvent) override |
void | cleanup () override |
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 | onPath (const Url &uri) |
Called when the URL path is known. More... | |
virtual int | onStatus (http_parser *parser) |
virtual int | onChunkHeader (http_parser *parser) |
virtual int | onChunkComplete (http_parser *parser) |
virtual bool | onProtocolUpgrade (http_parser *parser) |
Called when the HTTP protocol should be upgraded. More... | |
virtual void | onHttpError (http_errno error) |
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) |
err_t | onSslConnected (SSL *ssl) override |
void | pushAsyncPart () |
void | freeStreams () |
void | setBuffer (ReadWriteStream *stream) |
void | initialize (tcp_pcb *pcb) |
bool | internalConnect (IPAddress addr, uint16_t port) |
virtual err_t | onPoll () |
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 * | ssl = nullptr |
SSLCTX * | sslContext = nullptr |
SSL_EXTENSIONS * | sslExtension = nullptr |
bool | sslConnected = false |
uint32_t | sslOptions = 0 |
SslKeyCertPair | sslKeyCert |
bool | freeKeyCertAfterHandshake = false |
SslSessionId * | sslSessionId = nullptr |
bool | useSsl = false |
Static Protected Attributes | |
static const http_parser_settings | parserSettings |
Callback table for parser. More... | |
|
inlineinherited |
Allows setting of multiple SSL validators after a successful handshake.
callback | The callback function to be invoked on validation |
data | The data to pass to the callback |
bool | true on success, false on failure |
|
inlineinherited |
Frees the memory used for the key and certificate pair.
freeSslKeyCert()
instead
|
inlineinherited |
Frees the memory used for the key and certificate pair.
|
inlineinherited |
getResponse()->headers.getLastModifiedDate()
instead
|
inlineoverridevirtual |
|
inlineinherited |
Returns pointer to the current response.
HttpResponse* |
|
inlineinherited |
getResponse()->code
instead
|
inlineinherited |
getResponse()->headers[]
instead
|
inlineinherited |
getResponse()->headers
instead
|
inlineinherited |
getResponse()->getBody()
instead
|
inlineinherited |
getResponse()->headers.getServerDate()
instead
|
protectedvirtualinherited |
Initializes the http parser for a specific type of HTTP message.
type |
|
overrideprotectedvirtual |
Called when a piece of body data is received.
at | the data |
length |
int | 0 on success, non-0 on error |
Implements HttpConnection.
|
overrideprotectedvirtual |
Called when all headers are received.
headers | The processed headers |
int | 0 on success, non-0 on error |
Implements HttpConnection.
|
overrideprotectedvirtual |
Called when a new incoming data is beginning to come.
parser |
int | 0 on success, non-0 on error |
Implements HttpConnection.
|
overrideprotectedvirtual |
Called when the incoming data is complete.
parser |
int | 0 on success, non-0 on error |
Implements HttpConnection.
|
inlineprotectedvirtualinherited |
Called when the URL path is known.
uri |
int | 0 on success, non-0 on error |
Reimplemented in HttpServerConnection.
|
inlineprotectedvirtualinherited |
Called when the HTTP protocol should be upgraded.
parser |
bool | true on success |
Reimplemented in HttpServerConnection.
|
inlineinherited |
Requires (pins) the remote SSL certificate to match certain fingerprints.
fingerprint | The fingerprint data against which the match should be performed. Must be allocated on the heap and will be deleted after use. Do not re-use outside of this method. |
type | The fingerprint type - see SslFingerprintType for details. |
bool | true on success, false on failure |
|
inlineinherited |
Requires (pins) the remote SSL certificate to match certain fingerprints.
fingerprints | - passes the certificate fingerprints by reference. |
bool | true on success, false on failure |
|
protectedinherited |
Called after all headers have been received and processed.
|
inlineinherited |
Set or clear the callback for connection close.
completeCb | callback delegate or nullptr |
|
inlineinherited |
Sets a callback to be called when the object instance is destroyed.
TcpServerConnectionDestroyedDelegate | destroyedDelegate - callback |
|
inlineinherited |
Set or clear the callback for received data.
receiveCb | callback delegate or nullptr |
|
inlineinherited |
Sets client private key, certificate and password from memory.
const | uint8_t *keyData |
int | keyLength |
const | uint8_t *certificateData |
int | certificateLength |
const | char *keyPassword |
bool | freeAfterHandshake |
|
inlineinherited |
Sets client private key, certificate and password from memory.
SSLKeyCertPair | |
bool | freeAfterHandshake |
|
inlineinherited |
Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal.
const | uint8_t *keyData |
int | keyLength |
const | uint8_t *certificateData |
int | certificateLength |
const | char *keyPassword |
bool | freeAfterHandshake |
|
inlineinherited |
Sets private key, certificate and password from memory for the SSL connection If this methods is called from a client then it sets the client key and certificate If it is called from a server then it sets the server certificate and key. Server and Client certificates differ. Client certificate is used for identification. Server certificate is used for encrypt/decrypt the data. Make sure to use the correct certificate for the desired goal.
SSLKeyCertPair | |
bool | freeAfterHandshake |
|
virtualinherited |
Base write operation.
data | |
len | |
apiflags | TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE |
int | -1 on error |
Reimplemented in FtpDataStream.
|
protectedinherited |
Used internally to buffer arbitrary data via send() methods.
|
protectedinherited |
Header construction.
|
protectedinherited |
Full set of incoming headers.
|
staticprotectedinherited |
Callback table for parser.
|
protectedinherited |
The currently active stream being sent.
|
protectedinherited |
By default a TCP connection does not have a time out.