From c8b41452144d0d991e9e3b15f6972f06817c3b39 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Thu, 10 Oct 2019 05:17:22 +0200 Subject: [PATCH] Add a 'Content-Length: 0' header to initial POST requests The webserver lighttpd rejected POST requests without a Content-length header with "411 Length Required". See: https://github.com/nextcloud/desktop/issues/1473 Signed-off-by: Michael Schuster --- src/gui/creds/flow2auth.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/creds/flow2auth.cpp b/src/gui/creds/flow2auth.cpp index e570e01d4..3a9db471a 100644 --- a/src/gui/creds/flow2auth.cpp +++ b/src/gui/creds/flow2auth.cpp @@ -52,7 +52,11 @@ void Flow2Auth::openBrowser() // Step 1: Initiate a login, do an anonymous POST request QUrl url = Utility::concatUrlPath(_account->url().toString(), QLatin1String("/index.php/login/v2")); - auto job = _account->sendRequest("POST", url); + // add 'Content-Length: 0' header (see https://github.com/nextcloud/desktop/issues/1473) + QNetworkRequest req; + req.setHeader(QNetworkRequest::ContentLengthHeader, "0"); + + auto job = _account->sendRequest("POST", url, req); job->setTimeout(qMin(30 * 1000ll, job->timeoutMsec())); QObject::connect(job, &SimpleNetworkJob::finishedSignal, this, [this](QNetworkReply *reply) { -- 2.30.2