MCPcopy Create free account
hub / github.com/PABannier/bark.cpp / parse_header

Function parse_header

examples/server/httplib.h:3657–3688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3655
3656template <typename T>
3657inline bool parse_header(const char *beg, const char *end, T fn) {
3658 // Skip trailing spaces and tabs.
3659 while (beg < end && is_space_or_tab(end[-1])) {
3660 end--;
3661 }
3662
3663 auto p = beg;
3664 while (p < end && *p != ':') {
3665 p++;
3666 }
3667
3668 if (p == end) { return false; }
3669
3670 auto key_end = p;
3671
3672 if (*p++ != ':') { return false; }
3673
3674 while (p < end && is_space_or_tab(*p)) {
3675 p++;
3676 }
3677
3678 if (p < end) {
3679 auto key = std::string(beg, key_end);
3680 auto val = compare_case_ignore(key, "Location")
3681 ? std::string(p, end)
3682 : decode_url(std::string(p, end), false);
3683 fn(std::move(key), std::move(val));
3684 return true;
3685 }
3686
3687 return false;
3688}
3689
3690inline bool read_headers(Stream &strm, Headers &headers) {
3691 const auto bufsiz = 2048;

Callers 2

httplib.hFile · 0.85
read_content_chunkedFunction · 0.85

Calls 4

is_space_or_tabFunction · 0.85
stringFunction · 0.85
compare_case_ignoreFunction · 0.85
decode_urlFunction · 0.85

Tested by

no test coverage detected