diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-02-14 09:37:51 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-02-15 08:14:00 +0000 |
commit | c774c2906ec20ad376968a0436b162bebe98cdbd (patch) | |
tree | 699ecfcd6eae4fcb4d221db0c5bd1ab874408f32 /src/coap/qcoapprotocol.cpp | |
parent | 088ee510879a0ce45e82eed38167b3fd47becd9e (diff) |
Do not override the request token, if it was set before
Currently the request token is generated randomly, and even if
the user sets a token to the request, it is being overridden.
It makes sense to allow users to provide the desired token.
This is also useful for unit tests.
Change-Id: Ia45ec70a1eaa125bcd35e00fa2cce753d081ab9d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/coap/qcoapprotocol.cpp')
-rw-r--r-- | src/coap/qcoapprotocol.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp index 95a574d..2edbf69 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -99,7 +99,8 @@ void QCoapProtocol::sendRequest(QPointer<QCoapReply> reply, QCoapConnection *con // Set a unique Message Id and Token QCoapMessage *requestMessage = internalRequest->message(); internalRequest->setMessageId(d->generateUniqueMessageId()); - internalRequest->setToken(d->generateUniqueToken()); + if (internalRequest->token().isEmpty()) + internalRequest->setToken(d->generateUniqueToken()); internalRequest->setConnection(connection); d->registerExchange(requestMessage->token(), reply, internalRequest); |