vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt
http://vinipsmaker.github.io/tufao/
GNU Lesser General Public License v2.1
589 stars 179 forks source link

Data is truncated when using WebSocket to transfer data over 128k #100

Open harryhdk opened 3 years ago

harryhdk commented 3 years ago

version:1.4.5 protocol :websocket

When the amount of data over 128K, slot "newMessage" can only receive most of the data. I found the last part of the data is in priv->payload, so I modified the code.

websocket.cpp

if (priv->frame.fin()) {
        // FINAL
        if (priv->frame.isControlFrame()) {
            evaluateControlFrame();
        } else {
            if (priv->frame.opcode() == FrameType::CONTINUATION) {
                // CONTINUATION
                QByteArray chunk(priv->fragment);
                chunk.append(priv->payload); // add this line,  the last part of data
                priv->fragment.clear();
                priv->payload.clear();  // also clear
                emit newMessage(chunk);
            } else {
                // NON-CONTINUATION
                QByteArray chunk(priv->payload);
                priv->payload.clear();
                emit newMessage(chunk);
            }
        }
    } 

It seems that everything is ok Please help to check whether this modification is feasible,thanks

vinipsmaker commented 3 years ago

Looks good to me. Do you want to create a PR?

harryhdk commented 3 years ago

Looks good to me. Do you want to create a PR?

glad to,thank you