| 89 | } |
| 90 | |
| 91 | static size_t parseContentLength(const std::string& headers) |
| 92 | { |
| 93 | // headerValue is case-insensitive, so every spelling a client may send is |
| 94 | // covered without listing them here. |
| 95 | std::string value = TransferProto::headerValue(headers, "Content-Length"); |
| 96 | if (value.empty()) { |
| 97 | return 0; |
| 98 | } |
| 99 | return (size_t)strtoul(value.c_str(), nullptr, 10); |
| 100 | } |
| 101 | |
| 102 | // Per-recv idle timeout. The server is single-threaded, so without a bound a |
| 103 | // stalled (or malicious) client would hang the whole receiver indefinitely. |
no test coverage detected