Skip to content

Basic WebSocket Client Support in CLI #1697

@Muhammad-Tayyab-Bhutto

Description

@Muhammad-Tayyab-Bhutto

Checklist

  • I've searched for similar feature requests.

Enhancement request

Add Basic WebSocket Client Support (ws://, wss://)

Introduce minimal WebSocket support to HTTPie CLI, allowing users to:

  • Connect to a ws:// or wss:// endpoint
  • Send a single text message via CLI argument
  • Receive and print one response frame
  • Exit cleanly

When a WebSocket scheme is detected, the CLI should establish a WebSocket connection instead of performing an HTTP request.

Example usage:

http ws://echo.websocket.events message="hello"

Expected behavior:

  1. Establish WebSocket connection
  2. Send the provided message as a text frame
  3. Print the first received text frame
  4. Exit successfully

Basic error handling should cover:

  • Invalid WebSocket URLs
  • TLS errors (wss://)
  • Connection timeouts
  • Unsupported/binary frames

This feature is intentionally scoped to provide minimal, non-interactive WebSocket testing support.


Problem it solves

I'm frequently testing APIs that expose both HTTP and WebSocket endpoints. While HTTPie works well for HTTP/HTTPS requests, I need to switch to another tool when validating WebSocket behavior.

I’m trying to test real-time endpoints quickly from the terminal so that I can verify message flow without leaving my CLI workflow.

Adding minimal WebSocket support would:

  • Reduce context switching
  • Improve developer productivity
  • Make HTTPie more versatile for modern API development

Additional information, screenshots, or code examples

Proposed Scope Constraints

To keep the implementation focused and maintainable:

  • No interactive REPL mode
  • No continuous streaming session
  • No advanced protocol extensions
  • Single-message request/response flow only

Future enhancements (if needed) could extend this to streaming or interactive mode.

I would be happy to work on this enhancement and submit a pull request if the maintainers agree with the proposed scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or enhancementnewNeeds triage. Comments are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions