-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
feature - avoid utf-8 decoding for text frames #1376
Comments
I understand your use case and, indeed, you cannot do this with the current API. For receiving frames, it would mean an API like This raises the question of providing a symmetrical API for sending |
That would work quite well. I guess I misunderstood the code, because it looked to me as if the recv() method is decoupled from where the actual processing of inbound data (read_message()). The solution you propose would certainly be more flexible. |
just thinking about the send side, I think it really is less important. there aren't too many servers that are strict in what they accept, especially when they are expecting text. I think if we implement it for send, while the effect is the same (skip encode, skip decode), but the names of the options will be different, e.g: decode_text_frames=False for recv(), and send_as_text=True for send() |
Yes, we need to pick the names for both sides carefully and, ideally, consistently.
If we have two names, I'd like some symmetry e.g. using the words |
I'm finding myself in the same position, trying to send data encoded with Any chance this gets added? |
just because it is supposed to be in utf-8, doesn't mean I prefer it in that form. specifically, my usecase, is giving the data to orjson, and passing it around as an orjson.Fragment().
Here are the documents for that use case.
https://github.com/ijl/orjson#deserialize
https://github.com/ijl/orjson#fragment
looking at websockets code, if such a capability were to be implemented, it seems like we'd want to add an flag to WebSocketCommonProtocol() and then use it to force binary around the time it decides on whether to decode it or not, located here:
https://github.com/python-websockets/websockets/blob/main/src/websockets/legacy/protocol.py#L1053
I'd be happy to whip up a patch in case you would consider this feature request.
The text was updated successfully, but these errors were encountered: