You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys, I'm having a very weird problem, with the server I'm trying to setup. Everything seems to go well as far connecting to the server, but for some reason process() never gets triggered. Note I use server.setHandler() in my api to assign an instantiaton of the class below. Then I call server.listen(). Please see the code below:
`#ifndef HTTP_HANDLER_H
#define HTTP_HANDLER_H
#include
#include <qhttpengine/handler.h>
class HttpHandler : public QHttpEngine::Handler
{
Q_OBJECT
// Read the raw request data as a QByteArray
QByteArray requestData = socket->readAll();
// Process the raw data as needed
qDebug() << "Raw Request Data:" << requestData;
// You can now parse and handle the requestData
// For example, you can parse it as JSON if it's in JSON format:
// QJsonDocument jsonDocument = QJsonDocument::fromJson(requestData);
// QJsonObject jsonObject = jsonDocument.object();
// ... (perform further processing)
// Respond to the request (for example, with a simple OK response)
socket->setStatusCode(QHttpEngine::Socket::OK);
socket->writeHeaders();
socket->close();
emit messageReceived(socket, path);
}`
The text was updated successfully, but these errors were encountered:
Hi guys, I'm having a very weird problem, with the server I'm trying to setup. Everything seems to go well as far connecting to the server, but for some reason process() never gets triggered. Note I use server.setHandler() in my api to assign an instantiaton of the class below. Then I call server.listen(). Please see the code below:
`#ifndef HTTP_HANDLER_H
#define HTTP_HANDLER_H
#include
#include <qhttpengine/handler.h>
class HttpHandler : public QHttpEngine::Handler
{
Q_OBJECT
public:
HttpHandler(QObject* parent = nullptr);
virtual ~HttpHandler();
signals:
void messageReceived(QHttpEngine::Socket* socket, const QString& path);
protected:
void process(QHttpEngine::Socket *socket, const QString &path) override;
};
#endif
`
`#include "HttpHandler.h"
#include <qhttpengine/socket.h>
HttpHandler::HttpHandler(QObject *parent) : QHttpEngine::Handler(parent)
{
}
HttpHandler::~HttpHandler()
{
}
void HttpHandler::process(QHttpEngine::Socket *socket, const QString &path)
{
qDebug() << "HTTP request received! Path:" << path;
}`
The text was updated successfully, but these errors were encountered: