http status code in khtml
Miroslav Suchý
miroslav at suchy.cz
Fri Jan 27 15:04:49 GMT 2006
David Faure wrote:
> On Tuesday 24 January 2006 19:40, Miroslav Suchý wrote:
>>So I change and specify my question:
>>I have class derived from KHTMLPart and I need access to HTTP headers of
>>opened page. Can somebody point me where I can find it?
>>
> job->addMetaData("PropagateHttpHeader","true") should give you the
HTTP headers
> at the end of the job. When using KHTMLPart, you can connect to started(KIO::Job*) in order
> to get the job instance being used to download the stuff.
> Connect to the result signal, and in the slot there, use job->metaData("HTTP-Headers").
>
Thanks for your advice. But when I try it, I always get null value in
started(KIO::Job*). Here is my code:
HTTP::HTTP() : m_html(0) {
m_html = new KHTMLPart;
connect(m_html, SIGNAL(completed()), SLOT(slotCompleted()));
connect(m_html, SIGNAL(started(KIO::Job*)),
SLOT(transferStarted(KIO::Job*) ));
}
HTTP::open(const QString &path) {
m_html->openURL(path);
}
void HTTP::transferStarted( KIO::Job* job ) {
if ( job ) {
printf("job started\n");
job->addMetaData("PropagateHttpHeader","true");
connect(job, SIGNAL( result( KIO::Job * )),
SLOT( slotResult( KIO::Job * ) ) );
} else {
printf("job started - but no param\n");
}
}
void HTTP::slotResult( KIO::Job *job ) {
printf("job finished\n");
}
void HTTP::slotCompleted() {
m_completed = true;
printf("completed()\n");
}
When I call function open("http://kde.org") I get these result:
job started - but no param
completed()
Am I doing something wrong? Why I do not get job instance?
Miroslav Suchy
--
,,,
(o o)
=================================oOO==(_)==OOo===========
) mailto:miroslav at suchy.cz
( ICQ: #70802630 tel:+420-603-775737 skype:MiroslavSuchy
)
( "Programming today is a race between software engineers
) striving to build bigger and better idiot-proof programs,
( and the Universe trying to produce bigger and better idiots.
) So far, the Universe is winning." -- Rich Cook
(________________________________________Oooo._____________
.oooO ( )
( ) ) /
\ ( (_/
\_)
More information about the kfm-devel
mailing list