Help in debugging QNetworkReply::ProtocolInvalidOperationError
-
I have been using the
QtNetworkclasses successfully for a few years now to forward error data from the end-user of an application I have written through the internet as an email with attached ZIP file through a small PHP script installed on the web hosting server I subscribe to. As mentioned, there were no problems until recently.What the script does is to recognize HEAD, GET and POST requests. The HEAD request is used only to ensure that there is a working internet connection. Then a GET request is issued which returns a small captcha quiz consisting of a trivial arithmetic operation involving three numbers separated by the pipe symbol. The PHP file sets some session variables including the expected result of the captcha quiz.
The client, upon receiving the captcha quiz, emits a POST request containing form upload data including the ZIP file, the text of the email message, an MD5 hash of the ZIP file, and between one and five CC addresses. This has been working fine until some time this year.
Now I am getting the error mentioned in the subject of the thread. I assume that I need to set the correct protocol for the
QNetworkRequestobject before submitting the POST request. For HEAD and GET, setting this toQSsl::SecureProtocols(== 4) has been working; setting it toQSsl::TlsV1_2OrLateralso works for HEAD and GET, but in both cases it raises the same error mentioned for POST.I don't get any other output from the server. In the PHP script, I have
error_reporting(E_ALL)anddisplay_errorsis turned on, so if there were a PHP error, I would expect to see something. But maybe the server has turned this off?Also, since I am using Qt 6.10 by now, I don't see anything of interest when I call
QNetworkReply::headers(). I also connect a slot to theQNetworkManager::sslErrors()and display anything in aQMessageBox, but this slot is never called.Any hints as to how I can fix this?
-
Forgot to mention that the HTTP status code was 400 (Bad Request). Same thing when I don't try to set the SSL configuration manually, but just use the QNAM default.
-
No wonder, there was a formatting error in the form upload data --
mea culpa!Problem solved. -
R Robert Hairgrove has marked this topic as solved on