Skip to content

Commit ec133bb

Browse files
JosePineiroCopilotmathieucarbou
authored
refactor: optimize AsyncFileResponse handling (#240)
* refactor: optimize AsyncFileResponse handling This refactor improves AsyncFileResponse::AsyncFileResponse(File content, const String &path, const char *contentType, bool download, AwsTemplateProcessor callback) The updated implementation: - Replaces the use of String::endsWith() with a more efficient memcmp() check for gzip file suffix. - Fix the download of precompresed archives. The old behavior was wrong. - Simplifies content-disposition header generation using consistent logic for both inline and download cases. Overall, the refactor enhances performance slightly and ensures more consistent behavior when serving compressed downloadable files. * Add files via upload * Update src/WebResponses.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/WebResponses.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add files via upload --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mathieu Carbou <mathieu.carbou@gmail.com>
1 parent b658d62 commit ec133bb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/WebResponses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ AsyncFileResponse::AsyncFileResponse(File content, const String &path, const cha
758758
: AsyncAbstractResponse(callback) {
759759
_code = 200;
760760

761-
if (!download && String(content.name()).endsWith(T__gz) && !path.endsWith(T__gz)) {
761+
if (String(content.name()).endsWith(T__gz) && !path.endsWith(T__gz)) {
762762
addHeader(T_Content_Encoding, T_gzip, false);
763763
_callback = nullptr; // Unable to process gzipped templates
764764
_sendContentLength = true;

0 commit comments

Comments
 (0)