Skip to content
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

don't duplicate accept-encoding in vary header #2796

Merged
merged 1 commit into from Oct 2, 2015

Conversation

@ldesplat
Copy link
Contributor

@ldesplat ldesplat commented Sep 29, 2015

This is in relation hapijs/h2o2#17 .

accept-encoding value in vary header was being duplicated. This fixes the issue and adds a test case to cover the scenario.

I could have fixed it instead in lib/response.js, to not add a value if it already exists in a header but I thought that was too brittle to do there.

PS: forgot to say, I will make a lts PR if this is accepted.

@@ -227,7 +227,7 @@ internals.transmit = function (response, callback) {

// Content-Encoding

if (request.headers['accept-encoding']) {
if (request.headers['accept-encoding'] && (!response.headers.vary || response.headers.vary.indexOf('accept-encoding') === -1) ) {
response.vary('accept-encoding');
Copy link
Contributor

@hueniverse hueniverse Sep 29, 2015

Better done inside he response.vary() method in a generic way.

@ldesplat ldesplat force-pushed the fix-vary-duplicate branch from e2759c9 to 10f414e Sep 29, 2015
@ldesplat
Copy link
Contributor Author

@ldesplat ldesplat commented Sep 29, 2015

You are right and much easier. Updated the PR. Added 1 more test and kept the old one since I thought it was still relevant.

@ldesplat ldesplat force-pushed the fix-vary-duplicate branch from f45452b to c3b7b67 Sep 29, 2015

for (var i = 0, il = values.length; i < il; ++i) {
if (values[i] === value) {
foundMatch = true;
Copy link
Contributor

@hueniverse hueniverse Sep 29, 2015

Why not just return here?

Copy link
Contributor Author

@ldesplat ldesplat Sep 29, 2015

I would have but there appears to be opportunities to return early in this function and it was not done. So, I was following the current flow and decided to break. Returning early does save an allocation and I am already doing split so I just changed it. Thanks!

@ldesplat ldesplat force-pushed the fix-vary-duplicate branch from c3b7b67 to 1901987 Sep 29, 2015
@ldesplat
Copy link
Contributor Author

@ldesplat ldesplat commented Oct 2, 2015

Any update on this? I would love to get it going so I can do a PR for lts and get h2o2 updated! Thank you :)

@hueniverse hueniverse added the bug label Oct 2, 2015
@hueniverse hueniverse added this to the 10.2.0 milestone Oct 2, 2015
@hueniverse hueniverse self-assigned this Oct 2, 2015
hueniverse added a commit that referenced this issue Oct 2, 2015
don't duplicate accept-encoding in vary header
@hueniverse hueniverse merged commit 6c5ab9f into hapijs:master Oct 2, 2015
1 check passed
hueniverse added a commit that referenced this issue Oct 2, 2015
@ldesplat
Copy link
Contributor Author

@ldesplat ldesplat commented Oct 2, 2015

@nlf could this be included in LTS branch? h2o2 tests fail when upgrading to hapi 9.x.x otherwize.

@nlf
Copy link
Member

@nlf nlf commented Oct 2, 2015

it will be. i'll release a new LTS after 10.2.0 is released

@lock
Copy link

@lock lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants