summaryrefslogtreecommitdiffstats
path: root/src/oauth/qoauthhttpserverreplyhandler.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2025-10-09 07:28:41 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2025-10-09 15:29:36 +0300
commitc1b67207bd34ee973e5f4d11636f1558ec2a52d8 (patch)
tree197a07d5ded20b9674cf69f632ac2ac431ae64c7 /src/oauth/qoauthhttpserverreplyhandler.cpp
parent42b98d33481d4f50f04d27cc0568021920599f72 (diff)
parent43b96a2a65e58abeeb5d7c6c45cafe0f979152b7 (diff)
Merge tag 'v6.5.7-lts' into tqtc/lts-6.5-opensourcev6.5.7-lts-lgpl
Qt 6.5.7-lts release Conflicts solved: dependencies.yaml src/oauth/qabstractoauth.cpp Change-Id: If85eac30d0ca25fb7cefcea4d14f3ffa9ab95c24
Diffstat (limited to 'src/oauth/qoauthhttpserverreplyhandler.cpp')
-rw-r--r--src/oauth/qoauthhttpserverreplyhandler.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/oauth/qoauthhttpserverreplyhandler.cpp b/src/oauth/qoauthhttpserverreplyhandler.cpp
index 5dbcf4b..0e2c642 100644
--- a/src/oauth/qoauthhttpserverreplyhandler.cpp
+++ b/src/oauth/qoauthhttpserverreplyhandler.cpp
@@ -39,6 +39,13 @@ QOAuthHttpServerReplyHandlerPrivate::~QOAuthHttpServerReplyHandlerPrivate()
httpServer.close();
}
+QString QOAuthHttpServerReplyHandlerPrivate::callback() const
+{
+ const QUrl url(QString::fromLatin1("http://127.0.0.1:%1/%2")
+ .arg(callbackPort).arg(path));
+ return url.toString(QUrl::EncodeDelimiters);
+}
+
void QOAuthHttpServerReplyHandlerPrivate::_q_clientConnected()
{
QTcpSocket *socket = httpServer.nextPendingConnection();
@@ -251,11 +258,7 @@ QOAuthHttpServerReplyHandler::~QOAuthHttpServerReplyHandler()
QString QOAuthHttpServerReplyHandler::callback() const
{
Q_D(const QOAuthHttpServerReplyHandler);
-
- Q_ASSERT(d->httpServer.isListening());
- const QUrl url(QString::fromLatin1("http://127.0.0.1:%1/%2")
- .arg(d->httpServer.serverPort()).arg(d->path));
- return url.toString(QUrl::EncodeDelimiters);
+ return d->callback();
}
QString QOAuthHttpServerReplyHandler::callbackPath() const
@@ -296,7 +299,13 @@ quint16 QOAuthHttpServerReplyHandler::port() const
bool QOAuthHttpServerReplyHandler::listen(const QHostAddress &address, quint16 port)
{
Q_D(QOAuthHttpServerReplyHandler);
- return d->httpServer.listen(address, port);
+ const bool success = d->httpServer.listen(address, port);
+
+ if (success) {
+ // Callback ('redirect_uri') value may be needed after this handler is closed
+ d->callbackPort = d->httpServer.serverPort();
+ }
+ return success;
}
void QOAuthHttpServerReplyHandler::close()