Results 1 to 5 of 5

Thread: QHttp GET File & Password

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QHttp GET File & Password

    How to set password format to send on a server...
    I suppose not set on plain text ... hash or md5???

    Server apache2 make Ldap autenfication but is similar to .htpasswd

    http = new QHttp(this);
    http->setHost(urls.host(),80);
    http->setUser( current_user , current_pass );


    Qt Code:
    1. void Gui_Wget::downloadFile()
    2. {
    3. if (url.size() > 1 || currentfile.size() > 1 )
    4. {
    5. QUrl urls(url);
    6. if (is_file(currentfile)) {
    7. qt_unlink(currentfile);
    8. }
    9. file = new QFile(currentfile);
    10. if (!file->open(QIODevice::WriteOnly)) {
    11. QMessageBox::information(this, tr("File Error!"),
    12. tr("Unable to save the file %1: %2.")
    13. .arg(currentfile).arg(file->errorString()));
    14. delete file;
    15. file = 0;
    16. return;
    17. }
    18.  
    19. http = new QHttp(this);
    20. stopButton->setEnabled(true);
    21. http->setHost(urls.host(),80);
    22. http->setUser( current_user , current_pass );
    23.  
    24. statusLabel->setText(tr("Download Url:")+" "+url);
    25. connect(http, SIGNAL(dataReadProgress(int, int)),this, SLOT(updateDataReadProgress(int, int)));
    26. connect(http, SIGNAL(requestFinished(int, bool)),this, SLOT(httpRequestFinished(int, bool)));
    27. connect(http, SIGNAL(dataReadProgress(int, int)),this, SLOT(updateDataReadProgress(int, int)));
    28. connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
    29. connect(stopButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));
    30.  
    31. httpRequestAborted = false;
    32. httpGetId = http->get(urls.path(), file);
    33. downloadButton->setEnabled(false);
    34.  
    35. }
    36.  
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp GET File & Password


  3. The following user says thank you to wysota for this useful post:

    patrik08 (11th June 2006)

  4. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp GET File & Password

    so now by pass & user are 3 request!

    and must switch if user & pass ist set.... or only a simple get ....

    Qt Code:
    1. void Gui_Wget::readResponseHeader(const QHttpResponseHeader &responseHeader)
    2. {
    3. if (responseHeader.statusCode() != 200) {
    4. QMessageBox::information(this, tr("HTTP"),
    5. tr("Download failed message: %1. \nRemote file %2 not respond!")
    6. .arg(responseHeader.reasonPhrase() , url ));
    7. httpRequestAborted = true;
    8. http->abort();
    9. stopButton->setEnabled(false);
    10. emit ready_action();
    11. return;
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp GET File & Password

    Sorry, I don't have the slightest idea what you mean...

  6. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp GET File & Password

    readResponseHeader make 3 signal but now is running .... if isset password or no..

    I have post example to http://www.qtforum.de/forum/viewtopic.php?t=2269 on Snippets, Tipps & Tricks .... on german forum ... this forum not have a Snippets section ... ( as archive) is similar from qt4 http demo but other signal!

Similar Threads

  1. File Binary Upload QHttp find the bug/s
    By patrik08 in forum Qt Programming
    Replies: 13
    Last Post: 10th June 2008, 07:51
  2. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  3. QHttp has problems with some url's
    By whoops.slo in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2006, 23:16
  4. Accessing DTD in an XML file via QtXml module?
    By jorma in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2006, 18:09
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.