164 {
165 FL_WARN(
"APPROACH 2: await_top_level pattern with explicit types");
166
167
168
170 request_config.timeout(5000)
171 .header("User-Agent", "FastLED/NetTest-Tutorial");
172
173
174
176
177
178
179
181
182
184
185
187
188 FL_WARN(
"SUCCESS [Await] HTTP fetch successful! Status: "
190
191
192
195 FL_WARN(
"CONTENT [Await] Content-Type: " << *content_type);
196 }
197
198
200 if (response_body.
length() >= 100) {
201 FL_WARN(
"RESPONSE [Await] First 100 characters: " << response_body.
substr(0, 100));
202 } else {
203 FL_WARN(
"RESPONSE [Await] Full response (" << response_body.
length()
204 << " chars): " << response_body);
205 }
206
207
209 } else {
210
211
213
214
216 }
217}
StrN substr(fl::size start, fl::size length) const
Fetch options builder (fluent interface)
Promise class that provides fluent .then() and .catch_() semantics This is a lightweight wrapper arou...
fl::optional< fl::string > get_content_type() const
Get content type convenience method.
const fl::string & status_text() const
HTTP status text (like JavaScript response.statusText)
int status() const
HTTP status code (like JavaScript response.status)
const fl::string & text() const
Response body as text (like JavaScript response.text())
HTTP response class (unified interface)
const T & value() const
Get the success value (const)
bool ok() const
Check if the result is successful.
fl::string error_message() const
Get the error message as a convenience.
Result type for promise operations.
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
fl::result< T > await_top_level(fl::promise< T > promise)
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
fl::promise< response > fetch_get(const fl::string &url, const fetch_options &request)
HTTP GET request.
Representation of an RGB pixel (Red, Green, Blue)