| 3361 | } |
| 3362 | |
| 3363 | inline bool read_headers(Stream &strm, Headers &headers) { |
| 3364 | const auto bufsiz = 2048; |
| 3365 | char buf[bufsiz]; |
| 3366 | stream_line_reader line_reader(strm, buf, bufsiz); |
| 3367 | |
| 3368 | for (;;) { |
| 3369 | if (!line_reader.getline()) { return false; } |
| 3370 | |
| 3371 | // Check if the line ends with CRLF. |
| 3372 | auto line_terminator_len = 2; |
| 3373 | if (line_reader.end_with_crlf()) { |
| 3374 | // Blank line indicates end of headers. |
| 3375 | if (line_reader.size() == 2) { break; } |
| 3376 | #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR |
| 3377 | } else { |
| 3378 | // Blank line indicates end of headers. |
| 3379 | if (line_reader.size() == 1) { break; } |
| 3380 | line_terminator_len = 1; |
| 3381 | } |
| 3382 | #else |
| 3383 | } else { |
| 3384 | continue; // Skip invalid line. |
| 3385 | } |
| 3386 | #endif |
| 3387 | |
| 3388 | if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; } |
no test coverage detected