FastLED 3.9.15
Loading...
Searching...
No Matches
fl::response Class Reference

Detailed Description

HTTP response class (unified interface)

Definition at line 83 of file fetch.h.

#include <fetch.h>

+ Collaboration diagram for fl::response:

Public Member Functions

 response ()
 
 response (int status_code)
 
 response (int status_code, const fl::string &status_text)
 
const fl::stringget_body_text () const
 Response body as text (alternative to text())
 
fl::optional< fl::stringget_content_type () const
 Get content type convenience method.
 
fl::optional< fl::stringget_header (const fl::string &name) const
 Get header value (like JavaScript response.headers.get())
 
bool is_json () const
 Check if response appears to contain JSON content.
 
fl::Json json () const
 Response body parsed as JSON (JavaScript-like API)
 
bool ok () const
 Check if response is successful (like JavaScript response.ok)
 
void set_body (const fl::string &body)
 
void set_header (const fl::string &name, const fl::string &value)
 
void set_status (int status_code)
 Set methods (internal use)
 
void set_status_text (const fl::string &status_text)
 
void set_text (const fl::string &body)
 
int status () const
 HTTP status code (like JavaScript response.status)
 
const fl::stringstatus_text () const
 HTTP status text (like JavaScript response.statusText)
 
const fl::stringtext () const
 Response body as text (like JavaScript response.text())
 

Private Member Functions

fl::Json parse_json_body () const
 Parse JSON from response body with error handling.
 

Static Private Member Functions

static fl::string get_default_status_text (int status)
 

Private Attributes

fl::string mBody
 
fl::optional< fl::JsonmCachedJson
 
fl_map< fl::string, fl::stringmHeaders
 
bool mJsonParsed = false
 
int mStatusCode
 
fl::string mStatusText
 

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