-
Notifications
You must be signed in to change notification settings - Fork 8.5k
No response compression when there is a referer #47751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| throw new Error('Server is not created yet'); | ||
| } | ||
|
|
||
| this.server.ext('onRequest', (request, h) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to use registerOnPreAuth here because it doesn't expose the info. I'm assuming this generally isn't something we want to support, so I'm using the HapiJS interfaces directly. If you all think we should modify the KibanaRequest to include this, just let me know.
| registerRouter(router); | ||
|
|
||
| await server.start(); | ||
| const response = await innerServer.inject({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to use .inject here, as opposed to how the other tests are using supertest with the listener or else I wasn't able to use response.request.info. I also wasn't able to look at response.headers['content-encoding'] because this isn't being set by Hapi...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel great about testing implementation details rather than the actual HTTP response. It looks like supertest allows setting headers with the set method. Is it overriding it? If so, could we use a different way of sending a request in this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't either... Even if I set the request headers, the response coming back from HapiJS doesn't have the Content-Encoding header set, even though it ends up having it in the functional tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HapiJS seems to be skipping the actual compression in this situation, and it's not immediately obvious why: https://github.com/elastic/kibana/pull/47751/files#diff-51730cbab06a430a940f78fc9e710bd7R620-R637
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe not worth figuring out why since we do at least the functional test which covers the blackbox behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can look into it further to try to understand why. I gave up more easily than I usually do because.... hapi...
💔 Build Failed |
| registerRouter(router); | ||
|
|
||
| await server.start(); | ||
| const response = await innerServer.inject({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe not worth figuring out why since we do at least the functional test which covers the blackbox behavior.
|
|
||
| const router = new Router('', logger, enhanceWithContext); | ||
| router.get({ path: '/', validate: false }, (context, req, res) => | ||
| res.ok({ body: 'hello', headers: { 'Content-Type': 'text/html; charset=UTF-8' } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is threshold 1kB to enable gzip. Should fix the problem:
body: 'hello'.repeat(500), There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mikhail!
| await supertest(innerServer.listener) | ||
| .get('/') | ||
| .set('accept-encoding', 'gzip') | ||
| .then(response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid mixing async/await and promise syntax?
const response = await supertest(...);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's rather prevalent within this file, but sure!
mshustov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's switch to http interface instead of using hapi specific API.
To be able to use |
|
@kobelb sorry, I mean for tests. implementation is ok |
💔 Build Failed |
|
|
||
| const router = new Router('', logger, enhanceWithContext); | ||
| router.get({ path: '/', validate: false }, (context, req, res) => | ||
| res.ok({ body: 'hello'.repeat(500), headers: { 'Content-Type': 'text/html; charset=UTF-8' } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we add a comment why we make such a long body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, great idea. I will make it so.
💔 Build Failed |
💚 Build Succeeded |
|
@elasticmachine merge upstream |
💚 Build Succeeded |
* Hacking it in there, this is obviously not where this belongs * Moving implementation to a private method * Adding unit tests, I don't like the way I had to write these * Adding integration tests * Test not relying on implementation details... * No longer using .inject, thanks Mikhail!!! * Adding comment explaining the long body * Fixing nesting of describes for api integration tests
* Hacking it in there, this is obviously not where this belongs * Moving implementation to a private method * Adding unit tests, I don't like the way I had to write these * Adding integration tests * Test not relying on implementation details... * No longer using .inject, thanks Mikhail!!! * Adding comment explaining the long body * Fixing nesting of describes for api integration tests
* Hacking it in there, this is obviously not where this belongs * Moving implementation to a private method * Adding unit tests, I don't like the way I had to write these * Adding integration tests * Test not relying on implementation details... * No longer using .inject, thanks Mikhail!!! * Adding comment explaining the long body * Fixing nesting of describes for api integration tests
* Hacking it in there, this is obviously not where this belongs * Moving implementation to a private method * Adding unit tests, I don't like the way I had to write these * Adding integration tests * Test not relying on implementation details... * No longer using .inject, thanks Mikhail!!! * Adding comment explaining the long body * Fixing nesting of describes for api integration tests
This reverts commit 85e5885.
…" (elastic#49987) This reverts commit 85e5885.
When there is a "referer", this disables response compression.