mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Add Server::set_compress() to turn off handler response compression
A server built with compression support compressed every handler response the client accepted, with no way to turn it off. Over HTTPS the length of a compressed response can give away a secret in it when the same response also carries text an attacker chooses (BREACH). set_compress(false) sends handler responses, buffered or streamed, as they are; compression stays on by default, and static file compression keeps its own setting. The README and the cookbook describe the switch and when to use it.
This commit is contained in:
1 parent
3b8b9cf9d5
commit
fc37d3eae1
5 files changed
+67
-1
No files matched your search
@@ -1590,6 +1590,8 @@ This holds for every kind of response, including the file-backed ones below.
|
||||
|
||||
`Vary: Accept-Encoding` is added only to responses the server encoded itself. A handler that chooses between an encoded and an identity representation by reading `Accept-Encoding` should set the field itself, so that shared caches keep the two apart.
|
||||
|
||||
Turn this compression off with `svr.set_compress(false)`. Over HTTPS, the length of a compressed response can give away a secret in it, such as a CSRF token, when the same response also carries text an attacker can choose (the BREACH attack). A server whose responses mix the two should turn compression off, or keep such secrets out of those responses. Static file compression, below, is set separately.
|
||||
|
||||
### Static file compression
|
||||
|
||||
Responses served from a file, whether through `set_mount_point()` or `Response::set_file_content()`, are sent as is by default. Turn compression on for them with:
|
||||
|
||||
Reference in new issue
Block a user