PDA

View Full Version : QHttp GET File & Password



patrik08
10th June 2006, 16:40
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 );




void Gui_Wget::downloadFile()
{
if (url.size() > 1 || currentfile.size() > 1 )
{
QUrl urls(url);
if (is_file(currentfile)) {
qt_unlink(currentfile);
}
file = new QFile(currentfile);
if (!file->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("File Error!"),
tr("Unable to save the file %1: %2.")
.arg(currentfile).arg(file->errorString()));
delete file;
file = 0;
return;
}

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

statusLabel->setText(tr("Download Url:")+" "+url);
connect(http, SIGNAL(dataReadProgress(int, int)),this, SLOT(updateDataReadProgress(int, int)));
connect(http, SIGNAL(requestFinished(int, bool)),this, SLOT(httpRequestFinished(int, bool)));
connect(http, SIGNAL(dataReadProgress(int, int)),this, SLOT(updateDataReadProgress(int, int)));
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(stopButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));

httpRequestAborted = false;
httpGetId = http->get(urls.path(), file);
downloadButton->setEnabled(false);

}


}

wysota
10th June 2006, 18:22
See QHttp::setUser().

patrik08
11th June 2006, 04:12
so now by pass & user are 3 request!

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


void Gui_Wget::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
if (responseHeader.statusCode() != 200) {
QMessageBox::information(this, tr("HTTP"),
tr("Download failed message: %1. \nRemote file %2 not respond!")
.arg(responseHeader.reasonPhrase() , url ));
httpRequestAborted = true;
http->abort();
stopButton->setEnabled(false);
emit ready_action();
return;
}
}

wysota
11th June 2006, 09:33
Sorry, I don't have the slightest idea what you mean...

patrik08
11th June 2006, 14:04
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) :rolleyes: is similar from qt4 http demo but other signal!