|
FabGL2 2.0.0
ESP32 Display Controller and Graphics Library for ESP-IDF
|
HTTP connection and request helper. More...
#include <netutils.h>
Public Member Functions | |
| void | close () |
| Closes the HTTP connection. | |
| int | contentLength () |
| Gets the content length. | |
| int | GET (char const *URL) |
| Performs a GET request. | |
| int | open (char const *URL, int64_t rangeStart=0) |
| Opens a streaming GET request (follows redirects). | |
| int | read (void *buffer, int length) |
| Reads content after a successful open(). | |
| void | setTimeout (int timeoutMS) |
| Sets the network timeout of the next open() and GET(). | |
Public Attributes | |
| Delegate< void const *, int > | onData |
| Data received delegate. | |
HTTP connection and request helper.
HTTPRequest connects to a web server and downloads a page or a file.
Example:
auto nc = fabgl::WiFiConnection();
if (nc.connect("MySSID", "MyPassword")) {
fabgl::HTTPRequest req;
// just count the received bytes
int received = 0;
req.onData = [&](void const * data, int len) {
received += len;
};
// start GET method
if (req.GET("https://www.fabglib.org/schema_audio.png") == 200)
Term.printf("Received %d of %d bytes\r\n", received, req.contentLength());
}
Definition at line 280 of file netutils.h.