| 840 | } |
| 841 | |
| 842 | Result HttpAsyncFileServer::Internal::formatContentRange(const ByteRange& range, size_t fileSize, char* buffer, |
| 843 | size_t bufferSize, size_t& outLength) |
| 844 | { |
| 845 | outLength = static_cast<size_t>(snprintf( |
| 846 | buffer, bufferSize, "bytes %llu-%llu/%llu", static_cast<unsigned long long>(range.offset), |
| 847 | static_cast<unsigned long long>(range.offset + range.length - 1), static_cast<unsigned long long>(fileSize))); |
| 848 | if (outLength == 0 or outLength >= bufferSize) |
| 849 | { |
| 850 | return Result::Error("Failed to format Content-Range"); |
| 851 | } |
| 852 | return Result(true); |
| 853 | } |
| 854 | |
| 855 | Result HttpAsyncFileServer::Internal::formatUnsatisfiedContentRange(size_t fileSize, char* buffer, size_t bufferSize, |
| 856 | size_t& outLength) |