FastLED 3.10.8
Loading...
Searching...
No Matches
fl::net::http::FetchRequest Class Reference

Detailed Description

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 39 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) FL_NO_EXCEPT
 Construct a new fetch request.
 
 ~FetchRequest () FL_NO_EXCEPT
 Destructor - closes socket if still open.
 
State get_state () const FL_NO_EXCEPT
 Get current state.
 
bool is_done () const FL_NO_EXCEPT
 Check if request is complete (success or failure)
 
void update () FL_NO_EXCEPT
 Pump the state machine (called by fl::task every update interval)
 

Private Types

using SocketHandle = int
 

Private Member Functions

void close_socket () FL_NO_EXCEPT
 
void complete_error (const char *message) FL_NO_EXCEPT
 
void complete_success (const Response &resp) FL_NO_EXCEPT
 
void handle_connecting () FL_NO_EXCEPT
 
void handle_dns_lookup () FL_NO_EXCEPT
 
void handle_receiving () FL_NO_EXCEPT
 
void handle_sending () FL_NO_EXCEPT
 
Response parse_http_response (const fl::string &raw) FL_NO_EXCEPT
 

Private Attributes

size_t mBytesSent
 
::hostent * mDnsResult
 
fl::string mHostname
 
RequestOptions mOptions
 
fl::url mParsedUrl
 
fl::string mPath
 
int mPort
 
fl::task::Promise< Response > mPromise
 
fl::string mRequestBuffer
 
fl::string mResponseBuffer
 
SocketHandle mSocketFd
 
State mState
 
u32 mStateStartTime
 

The documentation for this class was generated from the following file: