Add support for serving Qt resources in their internal compressed form #320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Qt internal resources are often stored compressed. The two compression formats being zlib and zstd.
When Qt NAM connects it by default sends:
Accept-Encoding: gzip, deflate
deflate maps to zlib compression.
The PR adds a helper function that if the Accept-Encoding header matches the compression format used for the Qt resource then rather than uncompressing the data internally in the server the data is sent unmodified to the client. If the data is not in the requested format the data is uncompressed (if it was compressed in the first place) and sent as usual.
This also checks all the edge cases for Accept-Encoding such as only supporting compressed data and not plain text.
I've tested this for zlib compression, every Qt version I have currently have access to has zstd disabled so I have not tested that.
I did have an issue with the unit tests with conditionally enabling resources based on zstd being configured in Qt.
This was honestly just an experiment in whether Qt resources exactly matched the HTTP data formats and it turns out for zlib at least they do.