-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Want to implement rfc7692, but writer side can not be implemented #339
Comments
note The client of context-takeover uses python's one. I will post code that I am using for debugging if necessary. |
The code in conn.go is written to support context takeover. When context takeover is used, the compression factory functions (newDecompressionReader, newCompressionWriter) maintain per-connection state through a closure or a method value. This state will include the flate.Writer or flate.Reader for the connection. A method value implementation will look something like this:
The Upgrader.Upgrade and DIaler.Dial methods will setup the factory and assign a method value to the factory function fields:
The truncWriter, flateWriteWrapper and flateReadWrapper types are written to support no context takeover. A new set of types will be needed to support context takeover. |
Here's more of the sketch for implementing the context takeover writer. The truncWriter type can be used as is.
The setup code is:
I am not very happy with the type names I am suggesting here, but I don't have any better suggestions at the moment. The name |
Thank you very much. Initially, I thought that it was bad that I could not grasp the relationship between the dictionary used by flate.Writer and the window. Since the Reader side also implements forcible implementation, I think to rewrite it to Factory pattern. |
I could create readers and writers implementing context-takeover. If you do not plan to support context-takeover in your repository, I will develop it as Fork. Like this, if compress true and context-takeover true
|
Performance of Write is equivalent to that of NoContext
|
Yes
The RFC does not require the endpoint to support max_window_bits. |
Hi,
I'd like to use the context-takeover mechanism defined in rfc7692.
I forked and developed it and I could implement the reader side.
This [branch] (https://github.com/smith-30/websocket/tree/feature/upgrade_writer) is the newest.
However, I am in trouble because I can not implement the writer.
Implementation I'm thinking
Attempting to implement context-takeover by attaching flateWriteWrapper to Conn struct.
In flateWriteWrapper, attach flat.Writer called with flat.NewWriterDict.
https://github.com/smith-30/websocket/blob/ee46f8548a106a02264f711a1838887fd3cf58cf/conn.go#L518-L536
I do not want to make flateWriter every time I make a call.
Because performance is very poor.
Not using Pool is because GC may clean it without permission.
Avoid the window of flateWriter disappearing and inconsistency with reader side.
However, in my implementation I can not initialize the truncWriter passed to flateWriter.
In the second execution, truncWriter has state and fails in compress processing.
I'd like to reset the state of truncWriter after compression
Is there a good way to do it?
I am sorry for my poor English.
It would be extremely helpful If you review my implementation..
The text was updated successfully, but these errors were encountered: