Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support client_max_window_bits and server_max_window_bits compression options#534

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hexdigest wants to merge1 commit intocoder:master
base:master
Choose a base branch
Loading
fromhexdigest:client-max-window-bits

Conversation

hexdigest
Copy link

@hexdigesthexdigest commentedAug 12, 2025
edited
Loading

This is related andfixes#443

@hexdigest
Copy link
Author

Hey guys these ☝️ are failing due to thirdparty dependency.

@nhooyrthe third party dependency I introduce here is a well known drop in replacement for compress/flate. It also has constructors that allows you to specify the size of the window.

@mafredri
Copy link
Member

Hey@hexdigest. Thanks for the contribution! I'll need to read up on this a bit to give a proper review, so it might take a while.

In the meantime, I'm thinking an implementation that allows providing a custom flate implementation via options would be preferable. This way we don't need to add any external dependencies to this library, yet we support the use-case. It'd be fine to even include an example of how to do it as part of the go docs.

@mafredri
Copy link
Member

@hexdigest is this something you still want to work on?

@hexdigest
Copy link
Author

@hexdigest is this something you still want to work on?

Yep, I can do it. My only concern about the options approach is that depending on the provided flate implementation we should enable or disable certain compression options. But I guess this could be a part of flate abstraction interface (that can return a list of supported options) and manage pools.

Does it make sense to you?

@mafredri
Copy link
Member

What kind of use-cases are you considering?

Off the top of my head I could see us having something like this:

// Match stdlib flate.Writer, add release.typeFlateWriterinterface {io.WriteCloserFlush()errorReset(io.Writer)Release()// Allow backing implementation to restore to pool.}typeOptionsstruct {FlateWriterfunc(w io.Writer,bitsint)FlateWriter}

But open to other suggestions, especially if this doesn't cover some use-case.

@hexdigest
Copy link
Author

What kind of use-cases are you considering?

Off the top of my head I could see us having something like this:

// Match stdlib flate.Writer, add release.typeFlateWriterinterface {io.WriteCloserFlush()errorReset(io.Writer)Release()// Allow backing implementation to restore to pool.}typeOptionsstruct {FlateWriterfunc(w io.Writer,bitsint)FlateWriter}

I was thinking about something like this ☝️ maybe with the one minor difference which is putting Release() logic into Close() method of WriteCloser.

But the thing that I was talking about in the above message is that depending on the FlateWriter implementation the websocket implementation (e.g. *_max_window_bits) might or might not accept certain compression options passed by the client. So maybe we can add a method to this FlateWriter interface that returns compression options that it supports.

WDYT?

@mafredri
Copy link
Member

mafredri commentedSep 5, 2025
edited
Loading

I was thinking about something like this ☝️ maybe with the one minor difference which is putting Release() logic into Close() method of WriteCloser.

Yeah, that's honestly better 👍🏻

But the thing that I was talking about in the above message is that depending on the FlateWriter implementation the websocket implementation (e.g. *_max_window_bits) might or might not accept certain compression options passed by the client. So maybe we can add a method to this FlateWriter interface that returns compression options that it supports.

WDYT?

That could overcomplicate the interface. If I'm understanding you correctly, I think we could cover the use-case by addingCompressionServerWindowMaxBits andCompressionServerWindowMinBits toAcceptOptions? This way negotiation is driven by server policy, not by querying a particular writer. The writer just accepts the bits we already negotiated.

Usage would then look something like:

c,err:=websocket.Accept(w,r,&websocket.AcceptOptions{CompressionServerWindowMinBits:9,CompressionServerWindowMaxBits:15,CompressionFlateWriter:kpFlateWriter(kpflate.DefaultCompression),})funckpFlateWriter(levelint)func(io.Writer,int)FlateWriter {returnfunc(dst io.Writer,bitsint)FlateWriter {// ...    }}

Does that make sense?

Edit: Perhaps best to addCompression prefix to flate writer as well so all compression options look the same.

hexdigest reacted with thumbs up emoji

@mafredri
Copy link
Member

FYI@hexdigest I came across today that this library used to integrateklauspost/compress, removed in#240. The reason seems to have been that it was too big (#220). I see this as validating for the approach we've discussed here.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

unsupported permessage-deflate parameter: "client_max_window_bits=15" from client
3 participants
@hexdigest@mafredri@max-chechel-vc

[8]ページ先頭

©2009-2025 Movatter.jp