Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delivering a pointer to the QTcpSocket with the QHttpServerRequest #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/httpserver/qabstracthttpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void QAbstractHttpServerPrivate::handleReadyRead(QTcpSocket *socket,
Q_Q(QAbstractHttpServer);
Q_ASSERT(socket);
Q_ASSERT(request);

request->setSocket(socket);

if (!socket->isTransactionStarted())
socket->startTransaction();
Expand Down
3 changes: 2 additions & 1 deletion src/httpserver/qhttpserverrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ int QHttpServerRequestPrivate::onChunkComplete(http_parser *httpParser)
}

QHttpServerRequest::QHttpServerRequest(const QHostAddress &remoteAddress) :
d(new QHttpServerRequestPrivate(remoteAddress))
d(new QHttpServerRequestPrivate(remoteAddress)),
m_socket(nullptr)
{}

QHttpServerRequest::~QHttpServerRequest()
Expand Down
4 changes: 4 additions & 0 deletions src/httpserver/qhttpserverrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class Q_HTTPSERVER_EXPORT QHttpServerRequest
QVariantMap headers() const;
QByteArray body() const;
QHostAddress remoteAddress() const;

void setSocket(QTcpSocket *socket) {this->m_socket = socket;};
QTcpSocket* socket() const {return this->m_socket;} ;

private:
Q_DISABLE_COPY(QHttpServerRequest)
Expand All @@ -101,6 +104,7 @@ class Q_HTTPSERVER_EXPORT QHttpServerRequest
explicit QHttpServerRequest(const QHostAddress &remoteAddress);

QScopedPointer<QHttpServerRequestPrivate> d;
QTcpSocket * m_socket;
};

QT_END_NAMESPACE
Expand Down