diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-17 10:22:08 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-17 10:22:08 +0200 |
| commit | 0b86b204209d78f496721ac14ed33691d2c5db1e (patch) | |
| tree | b17f1cddc3820d260dda4d450c7b71c7dbd503ac /src/geminiclient.cpp | |
| parent | 5b14fc424462a5d3a5a509bd177c04e9cba2ce17 (diff) | |
| download | kristall-0b86b204209d78f496721ac14ed33691d2c5db1e.tar.gz | |
Makes cancelling gemini requests more robust.
Diffstat (limited to 'src/geminiclient.cpp')
| -rw-r--r-- | src/geminiclient.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/geminiclient.cpp b/src/geminiclient.cpp index 80f5742..afae454 100644 --- a/src/geminiclient.cpp +++ b/src/geminiclient.cpp @@ -36,6 +36,8 @@ bool GeminiClient::startRequest(const QUrl &url) if(url.scheme() != "gemini") return false; + // qDebug() << "start request" << url; + if(socket.state() != QTcpSocket::UnconnectedState) { socket.disconnectFromHost(); socket.close(); @@ -73,14 +75,18 @@ bool GeminiClient::isInProgress() const bool GeminiClient::cancelRequest() { + // qDebug() << "cancel request" << isInProgress(); if(isInProgress()) { this->is_receiving_body = false; this->socket.disconnectFromHost(); - this->socket.close(); this->buffer.clear(); this->body.clear(); - return this->socket.waitForDisconnected(250); + this->socket.waitForDisconnected(500); + this->socket.close(); + bool success = not isInProgress(); + // qDebug() << "cancel success" << success; + return success; } else { @@ -103,7 +109,7 @@ void GeminiClient::disableClientCertificate() void GeminiClient::socketEncrypted() { - qDebug() << "Pub key =" << socket.peerCertificate().publicKey().toPem(); + // qDebug() << "Pub key =" << socket.peerCertificate().publicKey().toPem(); QString request = target_url.toString(QUrl::FormattingOptions(QUrl::FullyEncoded)) + "\r\n"; |
