nitroshare / qhttpengine

HTTP server for Qt applications
MIT License
159 stars 76 forks source link

readChannelFinished() emitted twice if request has Content-Length header #21

Closed nathan-osman closed 6 years ago

nathan-osman commented 6 years ago

The QHttpEngine::Socket::readChannelFinished() signal is emitted twice if the following occurs:

  1. The Content-Length header is set on the request, causing the signal to be emitted when requestDataRead is equal or greater than requestDataTotal (see here)

  2. The physical transport (QTcpSocket) emits the readChannelFinished() signal, which is connected to QHttpEngine::Socket::readChannelFinished(), causing it to be emitted a second time (see here)

The correct behavior would be for the transport signal to be connected to a private slot that emits QHttpEngine::Socket::readChannelFinished() only if requestDataTotal is equal to -1.