diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-02-27 17:07:29 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-03-06 10:01:08 +0000 |
commit | d9d26033bb3945cf69654b505f85f9786e42eade (patch) | |
tree | de2a522d4a61b70abd2367648d4e7025af576e69 /src | |
parent | 09d1d3bf20acfdb194f91e38ebfa67cc641f0119 (diff) |
Fix URL adjustment for URLs with no schemev5.13.0-beta1
Prepend the "scheme://" part a to URL only if it is relative
and doesn't have a host. Non-relative URLs having a host already
contain the "://" part.
Change-Id: If2ac3db4f2eb0d18ffa1893415f44b9d2c85db26
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/coap/qcoapclient.cpp | 2 | ||||
-rw-r--r-- | src/coap/qcoaprequest.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp index e4fd763..09e171c 100644 --- a/src/coap/qcoapclient.cpp +++ b/src/coap/qcoapclient.cpp @@ -429,8 +429,6 @@ QCoapDiscoveryReply *QCoapClient::discover(QtCoap::MulticastGroup group, QUrl discoveryUrl; discoveryUrl.setHost(base); - QString scheme = d->connection->isSecure() ? QStringLiteral("coaps") : QStringLiteral("coap"); - discoveryUrl.setScheme(scheme); discoveryUrl.setPath(discoveryPath); QCoapRequest request(discoveryUrl); diff --git a/src/coap/qcoaprequest.cpp b/src/coap/qcoaprequest.cpp index e23c806..f3fdca8 100644 --- a/src/coap/qcoaprequest.cpp +++ b/src/coap/qcoaprequest.cpp @@ -295,10 +295,13 @@ QUrl QCoapRequest::adjustedUrl(const QUrl &url, bool secure) QUrl finalizedUrl = url; const auto scheme = secure ? CoapSecureScheme : CoapScheme; - if (url.isRelative()) + if (url.host().isEmpty() && url.isRelative()) { + // In some cases host address is mistaken for part of the relative path, + // prepending the scheme fixes this. finalizedUrl = url.toString().prepend(scheme + QLatin1String("://")); - else if (url.scheme().isEmpty()) + } else if (url.scheme().isEmpty()) { finalizedUrl.setScheme(scheme); + } if (url.port() == -1) { const auto port = secure ? QtCoap::DefaultSecurePort : QtCoap::DefaultPort; |