Commit d05708c1 authored by jan.koester's avatar jan.koester
Browse files

test

parent 914156da
Loading
Loading
Loading
Loading
+14 −15
Changes for src/http/WebSocketProxy.cpp: 14 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -267,25 +267,24 @@ void relayLoop(std::unique_ptr<netplus::socket> client,

            auto pumpOne = [&](netplus::socket &source, netplus::socket &destination) {
                try {
                    // Accepted/server-side netplus::ssl sockets deliberately do not pull raw
                    // TCP bytes from ssl::recvData(): while attached, the event loop owns that
                    // step and feeds TLS through prime_recv(). This WebSocket socket has been
                    // detached from that event loop, so the relay must take over the same raw
                    // read before asking TLS for decrypted application data. For plain TCP the
                    // base implementation is a harmless no-op; for client-side TLS this merely
                    // pre-fills the same buffer recvData() would otherwise fill itself.
                    netplus::buffer buf(16384);
                    size_t r = 0;
                    try {
                        r = source.recvData(buf, 0);
                    } catch (const netplus::NetException &e) {
                        if (e.getErrorType() != netplus::NetException::Note) throw;

                        // Accepted/server-side netplus::ssl sockets deliberately do not pull
                        // raw TCP bytes from ssl::recvData(): while attached, the event loop
                        // owns that step and feeds TLS through prime_recv(). This WebSocket
                        // socket has been detached, so take over that raw read and retry TLS.
                        // Calling recvData first is important: it drains any already-decrypted
                        // bytes before prime_recv encounters a later EOF. For plain TCP,
                        // prime_recv is a harmless no-op and the retry simply reports Note.
                        netplus::buffer raw(16384);
                        source.prime_recv(raw, 0);
                    } catch (const netplus::NetException &e) {
                        if (e.getErrorType() != netplus::NetException::Note) {
                            closed = true;
                            return;
                        }
                        r = source.recvData(buf, 0);
                    }

                    netplus::buffer buf(16384);
                    size_t r = source.recvData(buf, 0);
                    if (r == 0) {
                        closed = true;
                        return;