|
FastLED 3.9.15
|
Non-blocking HTTP request state machine.
Handles a single HTTP request using incremental state updates. Designed to be pumped by fl::task::every_ms() for true async operation.
State progression: DNS_LOOKUP -> CONNECTING -> SENDING -> RECEIVING -> COMPLETED/FAILED
Definition at line 24 of file fetch_request.h.
#include <fetch_request.h>
Collaboration diagram for fl::net::http::FetchRequest:Public Types | |
| enum | State { DNS_LOOKUP , CONNECTING , SENDING , RECEIVING , COMPLETED , FAILED } |
Public Member Functions | |
| FetchRequest (const fl::string &url, const FetchOptions &opts, fl::task::Promise< Response > promise) | |
| Construct a new fetch request. | |
| ~FetchRequest () FL_NOEXCEPT | |
| Destructor - closes socket if still open. | |
| State | get_state () const |
| Get current state. | |
| bool | is_done () const |
| Check if request is complete (success or failure) | |
| void | update () |
| Pump the state machine (called by fl::task every update interval) | |
Private Member Functions | |
| void | close_socket () |
| void | complete_error (const char *message) |
| void | complete_success (const Response &resp) |
| void | handle_connecting () |
| void | handle_dns_lookup () |
| void | handle_receiving () |
| void | handle_sending () |
| Response | parse_http_response (const fl::string &raw) |
Private Attributes | |
| size_t | mBytesSent |
| ::hostent * | mDnsResult |
| fl::string | mHostname |
| fl::url | mParsedUrl |
| fl::string | mPath |
| int | mPort |
| fl::task::Promise< Response > | mPromise |
| fl::string | mRequestBuffer |
| fl::string | mResponseBuffer |
| int | mSocketFd |
| State | mState |
| u32 | mStateStartTime |