GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — WebSocketClient silently drops query string from URL during handshake · Issue #2468 · yhirose/cpp-httplib

WebSocketClient silently drops query string from URL during handshake #2468

New issue
Copy link
New issue
Copy link
Closed
Closed
WebSocketClient silently drops query string from URL during handshake#2468
Copy link

Description

@uriba107
uriba107
opened on Jun 6, 2026
Issue body actions

Description

WebSocketClient strips the query string from the URL. The constructor calls parse_url() which correctly splits the URL into path and query components, but only path is stored in path_ — the query is discarded. The WebSocket upgrade handshake then sends:

GET /some/path HTTP/1.1

Instead of the expected:

GET /some/path?key=value HTTP/1.1

This violates RFC 6455 §4.1 which states the Request-URI must include the resource name (path + query).

Steps to Reproduce

httplib::ws::WebSocketClient ws(
    "wss://example.com/api/v1?token=ABC&session=123",
    {});

// ws.connect() sends:
//   GET /api/v1 HTTP/1.1
//
// Expected:
//   GET /api/v1?token=ABC&session=123 HTTP/1.1

Any WebSocket server that requires query parameters for authentication or routing will reject the connection (typically 401 or 403).

Root Cause

In the WebSocketClient constructor (httplib.h, around line 20230):

path_ = std::move(uc.path);
// uc.query is available here but never used

And in perform_websocket_handshake() (httplib.h, around line 8795):

std::string req_str = "GET " + path + " HTTP/1.1\r\n";
// path has no query string

Suggested Fix

Append the query string to path_ in the constructor:

path_ = std::move(uc.path);
if (!uc.query.empty()) { path_ += uc.query; }

uc.query already includes the leading ?, so this produces the correct Request-URI.

Affected Versions

Verified in v0.46.0 and v0.46.1. Also present on current master (as of 2026-06-06).

Workaround

Apply the one-line patch above, or avoid query parameters in WebSocket URLs (not always possible — some servers require auth tokens in query params).

Activity

  1. yhirose
    added a commit that references this issue on Jun 7, 2026

    Fix WebSocketClient dropping query string from URL during handshake (#…

    79d83fe
  2. yhirose commented on Jun 7, 2026

    @yhirose
    yhirose
    on Jun 7, 2026
    Owner
    More actions

    @uriba107 thanks for the report. It's now fixed.

    Reacted by zhenjing
  3. yhirose
    closed this as completedon Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.