MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / parse_header

Function parse_header

examples/server/httplib.h:3418–3449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3416
3417template <typename T>
3418inline bool parse_header(const char *beg, const char *end, T fn) {
3419 // Skip trailing spaces and tabs.
3420 while (beg < end && is_space_or_tab(end[-1])) {
3421 end--;
3422 }
3423
3424 auto p = beg;
3425 while (p < end && *p != ':') {
3426 p++;
3427 }
3428
3429 if (p == end) { return false; }
3430
3431 auto key_end = p;
3432
3433 if (*p++ != ':') { return false; }
3434
3435 while (p < end && is_space_or_tab(*p)) {
3436 p++;
3437 }
3438
3439 if (p < end) {
3440 auto key = std::string(beg, key_end);
3441 auto val = compare_case_ignore(key, "Location")
3442 ? std::string(p, end)
3443 : decode_url(std::string(p, end), false);
3444 fn(std::move(key), std::move(val));
3445 return true;
3446 }
3447
3448 return false;
3449}
3450
3451inline bool read_headers(Stream &strm, Headers &headers) {
3452 const auto bufsiz = 2048;

Callers 2

httplib.hFile · 0.70
read_content_chunkedFunction · 0.70

Calls 5

is_space_or_tabFunction · 0.85
compare_case_ignoreFunction · 0.85
decode_urlFunction · 0.85
stringFunction · 0.70
fnFunction · 0.50

Tested by

no test coverage detected