Skip to content

THRIFT-6271: Give TWebSocketServer a readAll() of its own - #3868

Merged
Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-6271
Sep 17, 2026
Merged

Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-6271

Conversation

@Jens-G

@Jens-G Jens-G commented Sep 16, 2026

Copy link
Copy Markdown
Member

JIRA: THRIFT-6271
Client: cpp

The inheritance chain is TWebSocketServerTHttpServerTHttpTransportTVirtualTransport<THttpTransport>.

  • TWebSocketServer overrides readAll_virt(), which does the handshake and reads the frames.
  • The non-virtual readAll() it inherited is TVirtualTransport<THttpTransport>::readAll(), which reads through THttpTransport::read().
  • A call through a TTransport reached the WebSocket code. A call on a TWebSocketServer read the HTTP stream and ended with "No more data to read.".

Change

TWebSocketServer defines a non-virtual readAll() that calls readAll_virt(), as the note on TVirtualTransport::readAll() suggests. A call on the concrete type now does what a call through TTransport does. The comment in the test file that described the old behaviour is updated.

Test

New case readAll_on_the_concrete_type_reads_frames in lib/cpp/test/TWebSocketServerTest.cpp:

  • It reads two frames through a TWebSocketServer<true>, once on the object and once through a TWebSocketServer<true>*.
  • Against the unmodified library it fails with TTransportException: No more data to read..

Verified with a CMake Release build with OpenSSL and ZLIB in the ubuntu-jammy image:

  • UnitTests passes in full.
  • git clang-format leaves the changed lines alone.

The test file is already listed in lib/cpp/test/Makefile.am, so the autotools build compiles it too. THRIFT-6231, still open, touches readFrame() in the same header but not these lines.

🤖 Generated with Claude Code

@mergeable mergeable Bot added the c++ Pull requests that update C++ code label Sep 16, 2026
@Jens-G Jens-G self-assigned this Sep 16, 2026
Client: cpp

TWebSocketServer overrides readAll_virt(), which reads WebSocket frames. The
non-virtual readAll() it inherited, however, comes from
TVirtualTransport<THttpTransport> and reads through THttpTransport::read().
A readAll() called on a TWebSocketServer, rather than through a TTransport,
therefore read the HTTP stream instead of the frame payload. TWebSocketServer
now defines readAll() to call readAll_virt(), as the note on
TVirtualTransport::readAll() suggests, so both calls behave alike.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Jens-G
Jens-G merged commit 39f5fdf into apache:master Sep 17, 2026
101 of 102 checks passed
@Jens-G
Jens-G deleted the THRIFT-6271 branch September 17, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Pull requests that update C++ code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant