mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kioslave: implement proxy and referrer metadata for http slave
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
69af879278
commit
fcd8ecf950
2 changed files with 20 additions and 3 deletions
|
@ -73,7 +73,7 @@ no-auth-prompt bool Flag that indicates that only cached authenticat
|
|||
PropagateHttpHeader bool Whether HTTP headers should be send back (read by http)
|
||||
|
||||
HTTP-Headers string The HTTP headers, concatenated, \n delimited. Requires
|
||||
PropagateHttpHeader to be set. (set by http)
|
||||
PropagateHttpHeader to be set. (set by http)
|
||||
|
||||
UseProxy string URL representing the proxy settings (read by http)
|
||||
ProxyUrls string Comma separated list of proxy urls. The first url in this list
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
#include "kcomponentdata.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// TODO: PropagateHttpHeader, charset, modified, accept and maybe caching
|
||||
|
||||
static inline QByteArray HTTPMIMEType(const QByteArray &contenttype)
|
||||
{
|
||||
const QList<QByteArray> splitcontenttype = contenttype.split(';');
|
||||
|
@ -134,6 +135,10 @@ void HttpProtocol::get(const KUrl &url)
|
|||
const QByteArray useragentbytes = metaData("UserAgent").toAscii();
|
||||
curl_easy_setopt(m_curl, CURLOPT_USERAGENT, useragentbytes.constData());
|
||||
}
|
||||
if (hasMetaData("UseProxy")) {
|
||||
const QByteArray proxybytes = metaData("UseProxy").toAscii();
|
||||
curl_easy_setopt(m_curl, CURLOPT_PROXY, proxybytes.constData());
|
||||
}
|
||||
CURLcode curlresult = curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, curllist);
|
||||
if (curlresult != CURLE_OK) {
|
||||
curl_slist_free_all(curllist);
|
||||
|
@ -150,6 +155,19 @@ void HttpProtocol::get(const KUrl &url)
|
|||
return;
|
||||
}
|
||||
|
||||
// added in v7.76.0
|
||||
#ifdef CURLINFO_REFERER
|
||||
char *curlreferrer = nullptr;
|
||||
curlresult = curl_easy_getinfo(m_curl, CURLINFO_REFERER, &curlreferrer);
|
||||
if (curlresult == CURLE_OK) {
|
||||
const QString httpreferrer = QString::fromAscii(curlreferrer);
|
||||
kDebug(7103) << "Referrer" << httpreferrer;
|
||||
setMetaData(QString::fromLatin1("referrer"), httpreferrer);
|
||||
} else {
|
||||
kWarning(7103) << "Could not get referrer info" << curl_easy_strerror(curlresult);
|
||||
}
|
||||
#endif
|
||||
|
||||
curl_slist_free_all(curllist);
|
||||
finished();
|
||||
}
|
||||
|
@ -165,7 +183,6 @@ void HttpProtocol::slotMIME()
|
|||
} else {
|
||||
kWarning(7103) << "Could not get info" << curl_easy_strerror(curlresult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HttpProtocol::slotData(const char* curldata, const size_t curldatasize)
|
||||
|
|
Loading…
Add table
Reference in a new issue