FastLED 3.9.15
Loading...
Searching...
No Matches

◆ parseStatusLine()

bool fl::HttpResponseParser::parseStatusLine ( )
private

Definition at line 389 of file http_parser.cpp.hpp.

389 {
390 auto crlfPos = findCRLF();
391 if (!crlfPos.has_value()) {
392 return false; // Need more data
393 }
394
395 // Extract status line
396 fl::string line(reinterpret_cast<const char*>(mBuffer.data()), crlfPos.value()); // ok reinterpret cast
397 consume(crlfPos.value() + 2); // +2 for CRLF
398
399 // Parse: "VERSION STATUS_CODE REASON_PHRASE"
400 size_t versionEnd = line.find(' ');
401 if (versionEnd == fl::string::npos) {
402 return false; // Invalid format
403 }
404
405 size_t statusEnd = line.find(' ', versionEnd + 1);
406 if (statusEnd == fl::string::npos) {
407 // No reason phrase (optional in HTTP/1.1)
408 statusEnd = line.size();
409 }
410
411 resp().version = line.substr(0, versionEnd);
412 fl::string statusStr = line.substr(versionEnd + 1, statusEnd - versionEnd - 1);
413
414 if (!parseInt(statusStr, resp().statusCode)) {
415 return false; // Invalid status code
416 }
417
418 if (statusEnd < line.size()) {
419 resp().reasonPhrase = line.substr(statusEnd + 1);
420 }
421
422 return true;
423}
fl::optional< size_t > findCRLF() const
HttpResponse & resp()
fl::vector< u8 > mBuffer
string substr(fl::size start, fl::size length) const FL_NOEXCEPT
static constexpr fl::size npos
Definition string.h:195
int parseInt(const char *str, fl::size len)
Parse an integer from a character buffer.
fl::string version
Definition http_parser.h:28
fl::string reasonPhrase
Definition http_parser.h:30

References consume(), fl::basic_string::find(), findCRLF(), mBuffer, fl::string::npos, fl::parseInt(), fl::HttpResponse::reasonPhrase, resp(), fl::basic_string::size(), fl::string::substr(), and fl::HttpResponse::version.

Referenced by feed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: