diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/qmlwebsockets/qmlwebsockets_plugin.h | 9 | ||||
-rw-r--r-- | src/websockets/qwebsocket.cpp | 13 | ||||
-rw-r--r-- | src/websockets/qwebsocket.h | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 22 |
4 files changed, 28 insertions, 18 deletions
diff --git a/src/imports/qmlwebsockets/qmlwebsockets_plugin.h b/src/imports/qmlwebsockets/qmlwebsockets_plugin.h index 749d830..0fc9435 100644 --- a/src/imports/qmlwebsockets/qmlwebsockets_plugin.h +++ b/src/imports/qmlwebsockets/qmlwebsockets_plugin.h @@ -42,13 +42,6 @@ #include <QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_QtWebSockets); -#endif -} - QT_BEGIN_NAMESPACE class QtWebSocketsDeclarativeModule : public QQmlExtensionPlugin @@ -57,7 +50,7 @@ class QtWebSocketsDeclarativeModule : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - QtWebSocketsDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + QtWebSocketsDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri); }; diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index 3472fe4..b9c6cc0 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -775,4 +775,17 @@ bool QWebSocket::isValid() const return d->isValid(); } +/*! + \since 5.12 + Returns the number of bytes that are waiting to be written. The bytes are written when control + goes back to the event loop or when flush() is called. + + \sa flush + */ +qint64 QWebSocket::bytesToWrite() const +{ + Q_D(const QWebSocket); + return d->m_pSocket ? d->m_pSocket->bytesToWrite() : 0; +} + QT_END_NAMESPACE diff --git a/src/websockets/qwebsocket.h b/src/websockets/qwebsocket.h index a80c47a..b8742e8 100644 --- a/src/websockets/qwebsocket.h +++ b/src/websockets/qwebsocket.h @@ -113,6 +113,8 @@ public: QSslConfiguration sslConfiguration() const; #endif + qint64 bytesToWrite() const; + public Q_SLOTS: void close(QWebSocketProtocol::CloseCode closeCode = QWebSocketProtocol::CloseCodeNormal, const QString &reason = QString()); diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index d233b66..9b27ad2 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -1108,16 +1108,18 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS headers << qMakePair(QString::fromLatin1(key), QString::fromLatin1(m_request.rawHeader(key))); - const QString handshake = - createHandShakeRequest(m_resourceName, - m_request.url().host() - % QStringLiteral(":") - % QString::number(m_request.url().port(port)), - origin(), - QString(), - QString(), - m_key, - headers); + const auto format = QUrl::RemoveScheme | QUrl::RemoveUserInfo + | QUrl::RemovePath | QUrl::RemoveQuery + | QUrl::RemoveFragment | QUrl::RemovePort; + const QString host = m_request.url().toString(format).mid(2); + const QString handshake = createHandShakeRequest(m_resourceName, + host % QStringLiteral(":") + % QString::number(m_request.url().port(port)), + origin(), + QString(), + QString(), + m_key, + headers); if (handshake.isEmpty()) { m_pSocket->abort(); Q_EMIT q->error(QAbstractSocket::ConnectionRefusedError); |