Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Alternative way to download a file from HTTP
alex-97 last edited by
I need to download a file from the Internet and transform it to a QString for later use (I don't need to save it). I have managed to do this by using QNetworkAccessManager and QNetworkRequest to download my file and read it. (You can view the code at "https://github.com/WinT-3794/WinT-Messenger/blob/master/src/updater.cpp
":https://github.com/WinT-3794/WinT-Messenger/blob/master/src/updater.cpp). Everything is working correctly, however, this kind of implementation requires to have OpenSSL installed (and linked with Qt) in order to work.
So my question is: Is there a way to download or read data from HTTP without needing OpenSSL in Qt?
Even if the solution still requires SSL, its much more easier than recompiling Qt (as the documentation said). First of all, you will need to tweak your *.pro file:
Add the following code:
QT += network
# Note: the path should be where you have installed OpenSSL
LIBS += -L"C:/OpenSSL-Win32/lib" -llibeay32
CONFIG += openssl-linked
LIBS += -lcrypto -lssl
Step two, once you finished compiling and deploying your app on Windows (I recommend windeployqt.exe for the job), copy the following DLLs from the OpenSSL directory to your app's directory:
Depending on your configuration, this step (copying *.so files on UNIX) shouldn't be necessary on Mac and/or Linux as the packages are already installed by default by most distributions.
@SGaist, thanks for the answer, it helped me to go to the correct path (instead of compiling Qt with OpenSSL).
From HTTP ? It's already supported. But you are accessing an HTTPS resources so technically currently no. However, you don't need to have OpenSSL linked, the default build loads OpenSSL dynamically so you only need to put the dlls besides your application when deployed.