Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QtNetworkAccessmanager download file created by cgi
QtWS25 Last Chance

QtNetworkAccessmanager download file created by cgi

Scheduled Pinned Locked Moved Qt WebKit
15 Posts 3 Posters 5.1k 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.
  • M Offline
    M Offline
    MikeWagman
    wrote on last edited by
    #1

    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
    Thanks

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Neutron Stein
      wrote on last edited by
      #2

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

      Never Seen !

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

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

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MikeWagman
          wrote on last edited by
          #4

          I am logging, I have solved that problem.

          But when I hit the url which looks something like

          http://192.168.1.xxx/the.cgi?file=45&start=135485145%end=13554654

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

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Neutron Stein
            wrote on last edited by
            #5

            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

            Never Seen !

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MikeWagman
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MikeWagman
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  Neutron Stein
                  wrote on last edited by
                  #8

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

                  Never Seen !

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    MikeWagman
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      MikeWagman
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        Neutron Stein
                        wrote on last edited by
                        #11

                        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)
                        @
                        connect(this,SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),SLOT(authenticationRequiredSlot(QNetworkReply*,QAuthenticator*)));
                        connect(this,SIGNAL(finished(QNetworkReply*)),SLOT(finishedSlot(QNetworkReply*)));
                        }
                        @

                        @
                        void YourClass::authenticationRequiredSlot(QNetworkReply *reply, QAuthenticator *auth){
                        auth->setUser("username");
                        auth->setPassword("pass");
                        }
                        @

                        Never Seen !

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          MikeWagman
                          wrote on last edited by
                          #12

                          void MainWindow::provideAuthenication(QNetworkReply *reply, QAuthenticator *ator)
                          {
                          qDebug() << "auth" << reply->readAll(); // this is just to see what we received
                          ator->setUser(QString("XXXr"));
                          ator->setPassword(QString("XXX"));
                          }

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

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            MikeWagman
                            wrote on last edited by
                            #13

                            [[blank-post-content-placeholder]]

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              MikeWagman
                              wrote on last edited by
                              #14

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

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                MikeWagman
                                wrote on last edited by
                                #15

                                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.

                                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