Qt World Summit: Register Today!

QtNetworkAccessmanager download file created by cgi

  • yes new to QtNetworkAccessmanager - have gotten into a password protected site, and I need to get data from a cgi that I pass parameters to (aka get) I call the url and it returns nothing, how do I get to the download hook. I have loaded static pages on the other side so I know I am getting through

    There is a device with an embedded web server that I want to get at the data from a windows app I am building, yet I need to leave the device secure.

    Can someone point me in the right direction. When I type the url into the browser it does after a couple of second give me the option to download the file.

    Not sure this is the right area, but it was my best guess

  • The qnetworkaccessmanager s authenticationRequired signal may help you. see doc for more informations

  • There is a "thread on the same question":http://qt-project.org/forums/viewthread/19134/ you might want to follow.

  • I am logging, I have solved that problem.

    But when I hit the url which looks something like


    it comes back with a file - how do I catch that

  • if you get a reply which must be your file then when the download is finished use reply->readAll() to get the content of the file

  • When I pull a web page I get a reply. Which is the web page. When I use that url the reply is ""

    Now that I watch it it opens another tab that closes when the file dialog comes up

  • So I guess the questiion is - page opens a new tab how do you get that?

  • When you hit the url in your browser is authentication required the first time before the download starts?

  • Yes - but that I think I have beat - as it's also required for web pages that I have loaded and looked at.

  • This is the header on the data

    GET /content/datalog.cgi?format=0&start=1341118789&end=1343537988&max=1000 HTTP/1.1
    Host: XXXXXXX
    Connection: keep-alive
    Authorization: Digest username="XXXr", realm="XXXX", nonce="XXXXXXXXXXXXXXX", uri="/content/XXX.cgi?format=0&start=1341118789&end=1343537988&max=1000", response="XXXXXXXXXXXXXXXXXXXXX", qop=auth, nc=000002c3, cnonce="XXXXXXXXXXXXXXXXXX"
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Referer: http://XXXX/content/
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

  • and when you try it using QNetworkAccessManager the reply is empty right?did you make the connection ask i told you?If not here is a piece of code.try it.
    -in the constructor(i have subclassed QNetworkAccessManager)

    void YourClass::authenticationRequiredSlot(QNetworkReply *reply, QAuthenticator *auth){

  • void MainWindow::provideAuthenication(QNetworkReply *reply, QAuthenticator *ator)
    qDebug() << "auth" << reply->readAll(); // this is just to see what we received

    Is what I was using it's called when I load the page - that does load, and when I call the cgi

  • [[blank-post-content-placeholder]]

  • I got it I can determine the result name from the request - I do a request for that file after sending the cgi data.

  • I can get some of the files and not others. Is there a way to determine a file when it open a tab and send the file through that.

Log in to reply