Brotli Support
See original GitHub issueJust curious if there are plans to add support for brotli compression?
Saw the implementation in ktor-server/ktor-server-core/src/io/ktor/features/Compression.kt
for Gzip and Deflate. Wanted my application to respond with a brotli compressed js script (as it is 30% smaller than the gzip version) but failed to overwrite the Content-Encoding in the response header with br.
Miserable attempt: (the file was already compressed outside of ktor)
get("/bundle.min.js") {
// attempt 1
call.respondFile(File("public/js/bundle.min.js.br"), {
setProperty(AttributeKey("Content-Type"), "application/octet-stream")
setProperty(AttributeKey("Content-Encoding"), "br")
finish()
})
// attempt 2 bout = ByteArrayOutputStream
call.respondWrite(ContentType.Application.OctetStream, HttpStatusCode.OK, { bout })
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Brotli Accept-Encoding/Content-Encoding - CanIUse
1 Supported in Chrome and Opera behind the 'Brotli Content-Encoding' flag · 2 Enabled since 27 May 2016 · 3 Support starting with...
Read more >Brotli Support - Akamai TechDocs
Brotli is an open-source, lossless data compression algorithm that has a higher compression rate than gzip. With Brotli Support enabled, the CDN can...
Read more >Brotli - Wikipedia
A successor to gzip, it is supported by all major web browsers and has become increasingly popular, as it provides better compression than...
Read more >Brotli Test - Verify Brotli Compression Support - KeyCDN Tools
Test if a server supports the Brotli compression. The Brotli algorithm, which is the successor of Gzip, allows better and faster compression results....
Read more >Cross Browser Compatibility of Brotli Accept-Encoding ...
Brotli Accept-Encoding/Content-Encoding is Not Supported on Safari 9, which means that any user who'd be accessing your page through Safari ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@soywiz FYI there is extension point for implementing custom content encodings:
https://github.com/ktorio/ktor/blob/2554c84782b5c16dfe5b7e74bf6eb9187d4678f3/ktor-server/ktor-server-tests/test/io/ktor/tests/server/features/CompressionTest.kt#L123
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.