Skip to content

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

@harryhdk

Description

@harryhdk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions