| 3222 | |
| 3223 | template <typename T> |
| 3224 | inline bool parse_header(const char *beg, const char *end, T fn) { |
| 3225 | // Skip trailing spaces and tabs. |
| 3226 | while (beg < end && is_space_or_tab(end[-1])) { |
| 3227 | end--; |
| 3228 | } |
| 3229 | |
| 3230 | auto p = beg; |
| 3231 | while (p < end && *p != ':') { |
| 3232 | p++; |
| 3233 | } |
| 3234 | |
| 3235 | if (p == end) { return false; } |
| 3236 | |
| 3237 | auto key_end = p; |
| 3238 | |
| 3239 | if (*p++ != ':') { return false; } |
| 3240 | |
| 3241 | while (p < end && is_space_or_tab(*p)) { |
| 3242 | p++; |
| 3243 | } |
| 3244 | |
| 3245 | if (p < end) { |
| 3246 | fn(std::string(beg, key_end), decode_url(std::string(p, end), false)); |
| 3247 | return true; |
| 3248 | } |
| 3249 | |
| 3250 | return false; |
| 3251 | } |
| 3252 | |
| 3253 | inline bool read_headers(Stream &strm, Headers &headers) { |
| 3254 | const auto bufsiz = 2048; |
no test coverage detected