Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Alternative way to download a file from HTTP
Forum Updated to NodeBB v4.3 + New Features

[Solved] Alternative way to download a file from HTTP

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alex-97
    wrote on last edited by
    #1

    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 += network

    win32* {
    # 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).

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved