| 3416 | |
| 3417 | template <typename T> |
| 3418 | inline 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 | |
| 3451 | inline bool read_headers(Stream &strm, Headers &headers) { |
| 3452 | const auto bufsiz = 2048; |
no test coverage detected