| 3655 | |
| 3656 | template <typename T> |
| 3657 | inline 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 | |
| 3690 | inline bool read_headers(Stream &strm, Headers &headers) { |
| 3691 | const auto bufsiz = 2048; |
no test coverage detected