summaryrefslogtreecommitdiffstats
path: root/src/oauth/qoauthhttpserverreplyhandler.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2025-10-12 23:00:27 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2025-10-12 23:00:27 +0300
commit147ab569694af7dd2a95c2227447c1147844f23c (patch)
tree197a07d5ded20b9674cf69f632ac2ac431ae64c7 /src/oauth/qoauthhttpserverreplyhandler.cpp
parentf3af3be2595966b74968295df1e919b2a47b5794 (diff)
parentc1b67207bd34ee973e5f4d11636f1558ec2a52d8 (diff)
Merge tag 'v6.5.7-lts-lgpl' into 6.5
Qt 6.5.7-lts-lgpl release
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()