Support brotli compression on the server side (#142334)

* Use brotli compression

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* Add integration test for brotli support

* Use import instead of require()

* Suppress build error on importing brok

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* add brok as explicit package dep

* add `server.compression.brotli` config settings

* update documentation

* fix test utils

* fix more test configs

* add tests for endpoints too

* remove against endpoint for now

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: pgayvallet <pierre.gayvallet@elastic.co>
This commit is contained in:
Tim Rühsen 2022-10-24 15:33:21 +02:00 committed by GitHub
parent 4e8a904a44
commit 8b0145c3a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 121 additions and 14 deletions

View file

@ -12,10 +12,10 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
describe('compression', () => {
const compressionSuite = (url: string) => {
it(`uses compression when there isn't a referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.then((response) => {
expect(response.header).to.have.property('content-encoding', 'gzip');
@ -24,7 +24,7 @@ export default function ({ getService }: FtrProviderContext) {
it(`uses compression when there is a whitelisted referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.set('referer', 'https://some-host.com')
.then((response) => {
@ -34,12 +34,27 @@ export default function ({ getService }: FtrProviderContext) {
it(`doesn't use compression when there is a non-whitelisted referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.set('referer', 'https://other.some-host.com')
.then((response) => {
expect(response.header).not.to.have.property('content-encoding');
});
});
it(`supports brotli compression`, async () => {
await supertest
.get(url)
.set('accept-encoding', 'br')
.then((response) => {
expect(response.header).to.have.property('content-encoding', 'br');
});
});
};
describe('compression', () => {
describe('against an application page', () => {
compressionSuite('/app/kibana');
});
});
}