Skip to content

Commit 40c9aad

Browse files
paulharrisgittiver
authored andcommitted
Do not compress when body is empty
This resolves #920 ... keep the body empty if already empty. Compression adds compression headers and overhead, and breaks assumptions later on when processing (eg) error 404.
1 parent 92dd693 commit 40c9aad

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/crow/http_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ namespace crow
231231
decltype(*middlewares_)>({}, *middlewares_, ctx_, req_, res);
232232
}
233233
#ifdef CROW_ENABLE_COMPRESSION
234-
if (handler_->compression_used())
234+
if (!res.body.empty() && handler_->compression_used())
235235
{
236236
std::string accept_encoding = req_.get_header_value("Accept-Encoding");
237237
if (!accept_encoding.empty() && res.compressed)

0 commit comments

Comments
 (0)