GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add default option by bjohansebas · Pull Request #191 · expressjs/compression

Conversation

@bjohansebas

@bjohansebas bjohansebas commented Sep 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

A new option is added to determine the default behavior when Accept-Encoding is not sent by the client, defaulting to identity.

closes #83

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas bjohansebas mentioned this pull request Sep 27, 2024
Release 1.8.0 #189
Closed
bjohansebas added 4 commits September 27, 2024 18:39
@bjohansebas
add test for default encoding
c87d82f
@bjohansebas
add functionality
b1644d9
@bjohansebas
support *
7b58257
@bjohansebas
add docs
5d6a827
@bjohansebas
bjohansebas marked this pull request as ready for review September 28, 2024 00:30
@bjohansebas bjohansebas changed the title [WIP]: feat: add default option feat: add default option Sep 28, 2024
@bjohansebas
fix logic
24609a6
@bjohansebas

bjohansebas commented Oct 3, 2024

Copy link
Copy Markdown
Member Author

Hi @IamLizu, could you review this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IamLizu

IamLizu commented Oct 3, 2024

Copy link
Copy Markdown
Member

Hey @bjohansebas 👋

Sure, I will read the relevant issues and then review this PR 👍

bjohansebas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

IamLizu
IamLizu reviewed Oct 4, 2024
View reviewed changes
Comment thread index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas requested a review from UlisesGascon October 15, 2024 02:15
@bjohansebas bjohansebas self-assigned this Oct 15, 2024
@bjohansebas
bjohansebas marked this pull request as draft November 3, 2024 19:58
@bjohansebas
Merge branch 'master' of github.com:expressjs/compression into add-de…
86d65a9
…fault-encoding
@bjohansebas
bjohansebas marked this pull request as ready for review November 3, 2024 20:05
@bjohansebas
bjohansebas requested a review from wesleytodd November 3, 2024 20:06
@bjohansebas bjohansebas added this to the 1.8.0 milestone Nov 3, 2024
@bjohansebas
bjohansebas requested a review from IamLizu November 3, 2024 20:41
IamLizu
IamLizu suggested changes Nov 5, 2024
View reviewed changes

@IamLizu IamLizu left a comment

Copy link
Copy Markdown
Member

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.

Hi @bjohansebas 👋

I'm generally 👍 of the concept of introducing an enforcement mechanism, as discussed in #83.

However, would you mind renaming the variable defaultEnconfig to something that doesn't conflict with zlib.createGzip or zlib.createDeflate? It seems this conflict may have led to the addition of the following block:

if (opts.defaultEncoding) {
    opts.defaultEncoding = undefined
}

I suggest enforceEncoding, more on this below. Renaming the variable would help keep the code clean, and it’s important that we avoid such conflicts.

Thanks so much for your understanding and effort!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas

bjohansebas commented Nov 5, 2024

Copy link
Copy Markdown
Member Author

@IamLizu Good catch

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas requested a review from IamLizu November 5, 2024 21:50
@bjohansebas
change defaultEncoding to enforceEnconding
7a3f9ef
IamLizu
IamLizu approved these changes Nov 6, 2024
View reviewed changes

@IamLizu IamLizu left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

LGTM 👍

There's something I should address. As we know, content negotiation is handled by negotiator here, and it is indeed negotiator's responsibility to choose the best method.

Maybe we are interfering with negotiator's responsibilities?

cc: @expressjs/express-tc

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas
Merge branch 'master' into add-default-encoding
66c0cb7
@bjohansebas

bjohansebas commented Nov 11, 2024

Copy link
Copy Markdown
Member Author

@UlisesGascon ping

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wesleytodd
wesleytodd requested changes Nov 14, 2024
View reviewed changes
Comment thread index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread index.js

// if no method is found, use the default encoding
if (encodingSupported.indexOf(enforceEncoding) !== -1 && !req.headers['accept-encoding']) {
method = enforceEncoding === '*' ? 'gzip' : enforceEncoding

@wesleytodd wesleytodd Nov 14, 2024

Copy link
Copy Markdown
Member

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 dont see * referenced anywhere but here. Can you describe why this is necessary when you could drop this check and just have folks pass gzip directly for this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bjohansebas bjohansebas Nov 16, 2024

Copy link
Copy Markdown
Member Author

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.

If * is not checked and changed, the deflate encoding would be applied as it’s the last one in the check (

compression/index.js

Lines 196 to 198 in 66c0cb7

stream = method === 'gzip'
? zlib.createGzip(opts)
: zlib.createDeflate(opts)
), and deflate is not the encoding we want to be applied, it should be gzip when it’s *.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@wesleytodd wesleytodd Jan 11, 2025

Copy link
Copy Markdown
Member

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.

Sorry but I don't follow your description? To me it looks like this value for the option (coming from the calling code) could just be dropped entirely.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bjohansebas bjohansebas Jan 11, 2025

Copy link
Copy Markdown
Member Author

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 haven't found a way to eliminate this check.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas
sort conditional
7e00d42
@bjohansebas
bjohansebas requested a review from wesleytodd November 16, 2024 19:46
@bjohansebas

bjohansebas commented Nov 24, 2024

Copy link
Copy Markdown
Member Author

@wesleytodd Is there any change I need to make?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas bjohansebas added the semver-minor label Dec 1, 2024
@bjohansebas
Merge branch 'master' of github.com:expressjs/compression into add-de…
d4d6722
…fault-encoding
@bjohansebas
bjohansebas merged commit f4e596c into expressjs:master Dec 5, 2024
@bjohansebas
bjohansebas deleted the add-default-encoding branch December 5, 2024 15:28
@bjohansebas bjohansebas mentioned this pull request Jan 8, 2025
release: 1.8.0 #212
Merged
wesleytodd
wesleytodd reviewed Jan 11, 2025
View reviewed changes

@wesleytodd wesleytodd left a comment

Copy link
Copy Markdown
Member

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 looks to me like this was merged with a pending "change requested" review. Is that the case?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread index.js

// if no method is found, use the default encoding
if (encodingSupported.indexOf(enforceEncoding) !== -1 && !req.headers['accept-encoding']) {
method = enforceEncoding === '*' ? 'gzip' : enforceEncoding

@wesleytodd wesleytodd Jan 11, 2025

Copy link
Copy Markdown
Member

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.

Sorry but I don't follow your description? To me it looks like this value for the option (coming from the calling code) could just be dropped entirely.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas

bjohansebas commented Jan 11, 2025

Copy link
Copy Markdown
Member Author

Sorry for merging this with a change request, I now know I need to wait until the approval is there.

wesleytodd reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wesleytodd wesleytodd mentioned this pull request Jan 20, 2025
refactor: simplify encoding negotiation logic #213
Merged
@bjohansebas bjohansebas mentioned this pull request May 11, 2025
feat(compression): add brotli options and enforceEncoding support DefinitelyTyped/DefinitelyTyped#72755
Merged
8 of 13 tasks
@nobodysfool nobodysfool mentioned this pull request Jul 18, 2025
Bump on-headers and compression userfrosting/UserFrosting#1291
Merged
@n-dering n-dering mentioned this pull request Jul 19, 2025
Bump on-headers and compression n-dering/snake_react#2
Open
@mtrezza mtrezza mentioned this pull request Oct 25, 2026
fix: Bump compression from 1.7.3 to 1.8.2 parse-community/relay-examples#32
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@wesleytodd wesleytodd wesleytodd requested changes
@UlisesGascon UlisesGascon Awaiting requested review from UlisesGascon
+1 more reviewer
@IamLizu IamLizu IamLizu approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bjohansebas bjohansebas

Labels

semver-minor

Projects

None yet

Milestone

1.8.0

Development

Successfully merging this pull request may close these issues.

Force compression to client don't work

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bjohansebas @IamLizu @wesleytodd
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.