vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt

Home Page:http://vinipsmaker.github.io/tufao/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

harryhdk opened this issue · comments

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

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

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

glad to,thank you