[Solved] Alternative way to download a file from HTTP
-
Hello,
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.Even if I have my problem theoretically solved, In would like to write an implementation that would not depend of OpenSSL to function. For example, I was thinking if a JavaScript method could work to solve my issue.
So my question is: Is there a way to download or read data from HTTP without needing OpenSSL in Qt?
Edit
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 += networkwin32* {
# Note: the path should be where you have installed OpenSSL
LIBS += -L"C:/OpenSSL-Win32/lib" -llibeay32
CONFIG += openssl-linked
}unix {
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:
- libeay32.dll
- libssl32.dll
- ssleay32.dll
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).
-
Hi,
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.