-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Clone PerMessageDeflateExtension values correctly #1439
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a566891
Correctly clone values provided by the setter
marci4 1e9fbbf
Reuse inflater/deflater
marci4 fe7635b
Provide a setter/getter to set the deflater level
marci4 4f4aed5
Extends tests to better test the deflater level
marci4 dfca00b
Add Constructor with custom compression level
marci4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Please insert:
and replace the new Inflater() calls in lines 169 and 177 with inflater.reset(), and the deflater.end() & new Deflater() calls in lines 247/248 with deflater.reset().
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.
We are not going to reuse the deflater/inflater for multiple clients
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.
Using reset however should be done, I agree
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.
Could you elaborate? If the user of this library wants to hand in a different inflater/deflater, why should that not be used?
Specific use case: I want to use BEST_COMPRESSION, not DEFAULT_COMPRESSION, to get the most out of compression (and both my servers and clients are powerful enough to put up that extra effort). That's why I hand in a new Deflater(Deflater.BEST_COMPRESSION, true) instance. I'd like that to work.
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.
The problem is that we create a new instance of a Draft (and therefore the provided extension with the custom deflater/inflater) for every new client connecting to the server.
https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/WebSocketImpl.java#L272
If we simply use the single instance provided by the user, we will get in trouble for the server implementation
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.
Ah, thanks, I see. I was just lucky that I was only using 1 server and client for my WebSocket compression tests.
Indeed, then an API change is needed to set Inflater and Deflater factories. Or, if we think that this flexibility is not needed, a setCompressionLevel(int level); API would do for me. Then this class would always instantiate the Inflater and Deflater objects, always with nowrap=true.
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.
Looking more into the documentation, I think that nowrap will always be true in our case
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.
Yeah I think so too. We only need the compression level, nowrap should be true.
@PhilipRoman you got any objections?
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.
My bad, there is no getter for the level/strategy of a Deflater.
Therefore:
new API -> setCompressionLevel()
remove getter/setter for Deflater/Inflater