MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / read_headers

Function read_headers

extern/include/cpp-httplib/httplib.h:3363–3385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3361}
3362
3363inline bool read_headers(Stream &strm, Headers &headers) {
3364 const auto bufsiz = 2048;
3365 char buf[bufsiz];
3366 stream_line_reader line_reader(strm, buf, bufsiz);
3367
3368 for (;;) {
3369 if (!line_reader.getline()) { return false; }
3370
3371 // Check if the line ends with CRLF.
3372 auto line_terminator_len = 2;
3373 if (line_reader.end_with_crlf()) {
3374 // Blank line indicates end of headers.
3375 if (line_reader.size() == 2) { break; }
3376#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
3377 } else {
3378 // Blank line indicates end of headers.
3379 if (line_reader.size() == 1) { break; }
3380 line_terminator_len = 1;
3381 }
3382#else
3383 } else {
3384 continue; // Skip invalid line.
3385 }
3386#endif
3387
3388 if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }

Callers 1

process_requestMethod · 0.85

Calls 3

getlineMethod · 0.80
end_with_crlfMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected