THRIFT-6271: Give TWebSocketServer a readAll() of its own - #3868
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA: THRIFT-6271
Client: cpp
The inheritance chain is
TWebSocketServer→THttpServer→THttpTransport→TVirtualTransport<THttpTransport>.TWebSocketServeroverridesreadAll_virt(), which does the handshake and reads the frames.readAll()it inherited isTVirtualTransport<THttpTransport>::readAll(), which reads throughTHttpTransport::read().TTransportreached the WebSocket code. A call on aTWebSocketServerread the HTTP stream and ended with "No more data to read.".Change
TWebSocketServerdefines a non-virtualreadAll()that callsreadAll_virt(), as the note onTVirtualTransport::readAll()suggests. A call on the concrete type now does what a call throughTTransportdoes. The comment in the test file that described the old behaviour is updated.Test
New case
readAll_on_the_concrete_type_reads_framesinlib/cpp/test/TWebSocketServerTest.cpp:TWebSocketServer<true>, once on the object and once through aTWebSocketServer<true>*.TTransportException: No more data to read..Verified with a CMake Release build with OpenSSL and ZLIB in the
ubuntu-jammyimage:UnitTestspasses in full.git clang-formatleaves 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, touchesreadFrame()in the same header but not these lines.🤖 Generated with Claude Code