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. QNetworkManager Http Post binary file - error connection closed
Forum Updated to NodeBB v4.3 + New Features

QNetworkManager Http Post binary file - error connection closed

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 258 Views
  • 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.
  • Q Offline
    Q Offline
    qtanmarcot
    wrote on last edited by
    #1

    hello,

    I am using QNetworkManager to post a binary file on a server. I can post an Xml file , but when I try to post the binary file , I don't get any response from server and the reply's error is connection closed.

    here some snippet of my code:

    QNetworkRequest lQNetworkRequest;
    QNetworkRequest.setUrl(QUrl ("http://10.0.x.X/cgi-bin/file.cgi"));
    lQNetworkRequest.setHeader (QNetworkRequest::ContentDispositionHeader, "form-data;name=\"file\";filename=\"MYFILE.bin\"");
    lQNetworkRequest.setHeader (QNetworkRequest::ContentTypeHeader, "application/binary");
    
    aFile = new QFile ("MYFILE.bin");
    aFile->open (QIODevice::ReadOnly)
    aNetworkReply = aQnam->post(kpQNetworkRequest, aFile);
    connect(aNetworkReply , SIGNAL(finished()), this, SLOT(mvHttpFinished()))
    connect(aNetworkReply , SIGNAL(readyRead()), this, SLOT(mvHttpReadyRead()))
    

    My function mvHttpFinished is called and I got the aNetworkReply->error = 2 = Connection closed.

    Maybe I miss some important information in the header ? I am not about the ContentTypeHeader . I saw you can use application/octet-stream

    anyone can help me?
    thanks,
    Andre

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Since we don't know what your server needs we can't really help here.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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