diff --git a/src/include/qhttpengine/qobjecthandler.h b/src/include/qhttpengine/qobjecthandler.h index ed8a43b..dfbc478 100644 --- a/src/include/qhttpengine/qobjecthandler.h +++ b/src/include/qhttpengine/qobjecthandler.h @@ -39,8 +39,9 @@ class QHTTPENGINE_EXPORT QObjectHandlerPrivate; * * This handler enables incoming requests to be processed by slots in a * QObject-derived class or functor. Methods are registered by providing a - * name and slot to invoke. The slot may take a pointer to the - * [Socket](@ref QHttpEngine::Socket) for the request as an argument. + * name and slot to invoke. The slot must take a pointer to the + * [Socket](@ref QHttpEngine::Socket) for the request as an argument and + * must also close the socket when finished with it. * * To use this class, simply create an instance and call the appropriate * registerMethod() overload. For example: @@ -68,6 +69,7 @@ class QHTTPENGINE_EXPORT QObjectHandlerPrivate; * QHttpEngine::QObjectHandler handler; * handler.registerMethod("something", [](QHttpEngine::Socket *socket) { * // do something + * socket->close(); * }); * @endcode */ diff --git a/src/src/handler.cpp b/src/src/handler.cpp index dbcd9d0..c281e1f 100644 --- a/src/src/handler.cpp +++ b/src/src/handler.cpp @@ -92,5 +92,4 @@ void Handler::process(Socket *socket, const QString &) { // The default response is simply a 404 error socket->writeError(Socket::NotFound); - socket->close(); } diff --git a/src/src/qobjecthandler.cpp b/src/src/qobjecthandler.cpp index 3adcecb..fdf3330 100644 --- a/src/src/qobjecthandler.cpp +++ b/src/src/qobjecthandler.cpp @@ -92,11 +92,9 @@ void QObjectHandler::process(Socket *socket, const QString &path) // already the case, otherwise, wait until the rest of it arrives if (!m.readAll || socket->bytesAvailable() >= socket->contentLength()) { d->invokeSlot(socket, m); - socket->close(); } else { connect(socket, &Socket::readChannelFinished, [this, socket, m]() { d->invokeSlot(socket, m); - socket->close(); }); } }