Skip to content
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

Binary response frames are not handled well #216

Open
pliardb opened this issue Feb 2, 2024 · 5 comments
Open

Binary response frames are not handled well #216

pliardb opened this issue Feb 2, 2024 · 5 comments

Comments

@pliardb
Copy link

pliardb commented Feb 2, 2024

Unless I'm misusing websocat there appears to be two issues with how it handles binary response frames:

  • An extra trailing \n is added to the payload
  • \n characters within the payload are replaced with space characters. The payload should be returned as-is, without any byte conversion

Perhaps I missed a particular command-line flag to use? Thank you.

@vi
Copy link
Owner

vi commented Feb 2, 2024

-b ?

@pliardb
Copy link
Author

pliardb commented Feb 2, 2024

Thanks a lot for the very quick reply. I'll give this a try and report back. I may have seen and discarded this option earlier when seeing in the description message that it applied to the request (in my case the request is in text and the response in binary). I should have given it a chance though.

@vi
Copy link
Owner

vi commented Feb 2, 2024

--dump-spec option shows debugging output, depicting auto-inserted message-to-line and line-to-message convertors in text mode (which is the default).

Those conversions allow scripts to rely on one message = one line. --no-line and --no-fixups turn off those auto things.

@pliardb
Copy link
Author

pliardb commented Feb 7, 2024

Thanks a lot, --no-fixups did the trick. Perhaps websocat could default to this when dealing with a binary response frame. Though I think this particular issue could probably be closed given the existence of --no-fixups.

@vi
Copy link
Owner

vi commented Feb 7, 2024

By default Websocat assumes text messages to be sent and received and is aimed primarily at interactive testing of WebSocket endpoints (e.g. using something rlwrap websocat ws://127.0.0.1:8080).

-b switches it to binary mode, aimed primarily at websocat -b ... < upload_file > download_file or interconnection with a plain TCP.

There are other, trickier modes for mixing text and binary messages flexibly.

--no-fixups also turns off lints (warning messages when Websocat detects potentially problematic command line) and can lead to errors when advanced features are used, so it seems to be a poor default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants