mirror of https://github.com/qt/qtgrpc.git
QGrpcHttp2Channel: Add QLocalSocket abstract namespace support
QLocalSocket supports abstract namespaces. Grpc also supports it. Simply make it available through the 'unix-abstract' scheme. Ref: https://grpc.github.io/grpc/core/md_doc_naming.html Ref: https://doc.qt.io/qt-6/qlocalsocket.html#SocketOption-enum [ChangeLog][GRPC][QGrpcHttp2Channel] Added abstract namespace support for QLocalSocket communication through the "unix-abstract" scheme. Fixes: QTBUG-134273 Change-Id: Iea2b608478e00504d7cdbdff735fcbfb618529d7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
65358c24f6
commit
6a9810ed7f
|
@ -117,6 +117,7 @@ using namespace QtGrpc;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr QLatin1String UnixScheme("unix");
|
constexpr QLatin1String UnixScheme("unix");
|
||||||
|
constexpr QLatin1String UnixAbstractScheme("unix-abstract");
|
||||||
constexpr QLatin1String HttpScheme("http");
|
constexpr QLatin1String HttpScheme("http");
|
||||||
#if QT_CONFIG(ssl)
|
#if QT_CONFIG(ssl)
|
||||||
constexpr QLatin1String HttpsScheme("https");
|
constexpr QLatin1String HttpsScheme("https");
|
||||||
|
@ -687,10 +688,13 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nonDefaultPort = false;
|
bool nonDefaultPort = false;
|
||||||
|
const auto scheme = hostUri.scheme();
|
||||||
#if QT_CONFIG(localserver)
|
#if QT_CONFIG(localserver)
|
||||||
if (hostUri.scheme() == UnixScheme) {
|
if (scheme == UnixScheme || scheme == UnixAbstractScheme) {
|
||||||
hostUri.setScheme(HttpScheme);
|
hostUri.setScheme(HttpScheme);
|
||||||
auto *localSocket = initSocket<QLocalSocket>();
|
auto *localSocket = initSocket<QLocalSocket>();
|
||||||
|
if (scheme == UnixAbstractScheme)
|
||||||
|
localSocket->setSocketOptions(QLocalSocket::AbstractNamespaceOption);
|
||||||
m_isLocalSocket = true;
|
m_isLocalSocket = true;
|
||||||
|
|
||||||
QObject::connect(localSocket, &QLocalSocket::connected, this,
|
QObject::connect(localSocket, &QLocalSocket::connected, this,
|
||||||
|
@ -709,7 +713,7 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if QT_CONFIG(ssl)
|
#if QT_CONFIG(ssl)
|
||||||
if (hostUri.scheme() == HttpsScheme || channelOptions.sslConfiguration()) {
|
if (scheme == HttpsScheme || channelOptions.sslConfiguration()) {
|
||||||
ensureSchemeIsValid(HttpsScheme);
|
ensureSchemeIsValid(HttpsScheme);
|
||||||
auto *sslSocket = initSocket<QSslSocket>();
|
auto *sslSocket = initSocket<QSslSocket>();
|
||||||
if (hostUri.port() < 0) {
|
if (hostUri.port() < 0) {
|
||||||
|
|
Loading…
Reference in New Issue