Http request with QNetworkRequest placing resolved ip address in HTTP host header not domain
-
I'm using wkhtmltopdf which is built on QT. When trying to run through a proxy that only allows whitelisted domains, I noticed that the http host header is being set with the resolved ip address versus the host name like a browser would set. Any ideas why this might be happening?
The request is made with
//multiPageLoader.cookieJar->clearExtraCookies(); typedef QPair<QString, QString> SSP; foreach (const SSP & pair, settings.cookies) multiPageLoader.cookieJar->useCookie(url, pair.first, pair.second); QNetworkRequest r = QNetworkRequest(url); typedef QPair<QString, QString> HT; foreach (const HT & j, settings.customHeaders) r.setRawHeader(j.first.toLatin1(), j.second.toLatin1()); if (postData.isEmpty()) webPage.mainFrame()->load(r); else { if (hasFiles) r.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data, boundary=")+boundary); webPage.mainFrame()->load(r, QNetworkAccessManager::PostOperation, postData); }
-
I'm using wkhtmltopdf which is built on QT. When trying to run through a proxy that only allows whitelisted domains, I noticed that the http host header is being set with the resolved ip address versus the host name like a browser would set. Any ideas why this might be happening?
The request is made with
//multiPageLoader.cookieJar->clearExtraCookies(); typedef QPair<QString, QString> SSP; foreach (const SSP & pair, settings.cookies) multiPageLoader.cookieJar->useCookie(url, pair.first, pair.second); QNetworkRequest r = QNetworkRequest(url); typedef QPair<QString, QString> HT; foreach (const HT & j, settings.customHeaders) r.setRawHeader(j.first.toLatin1(), j.second.toLatin1()); if (postData.isEmpty()) webPage.mainFrame()->load(r); else { if (hasFiles) r.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data, boundary=")+boundary); webPage.mainFrame()->load(r, QNetworkAccessManager::PostOperation, postData); }
@jasonparallel
what is the value of theurl
variable? -
@jasonparallel
what is the value of theurl
variable?@raven-worx It it a Qurl. I added a printf to ensure it is holding the url using the domain name and it is. For example in my test https://thehackernews.com
Running it through charles proxy shows the IP being specified in the host header param
To compare this is a browser hitting the url
-
Version 4.8
-
7 years old and unsupported so might be a minor bug that was since resolved (I haven't tested Qt 5.10)
@VRonin It might be related to QNetworkProxy::HostNameLookupCapability. I'm looking into it
-
@VRonin It might be related to QNetworkProxy::HostNameLookupCapability. I'm looking into it
-
The issue was resolved by specifying QNetworkProxy::HostNameLookupCapability. I'm not sure if that is the desired effect to have no trace of the host at/past the proxy when it is not specified. It seems like that would cause issues when multiple domains share an ip.
-
The issue was resolved by specifying QNetworkProxy::HostNameLookupCapability. I'm not sure if that is the desired effect to have no trace of the host at/past the proxy when it is not specified. It seems like that would cause issues when multiple domains share an ip.
It is also only for https (http sends the hostname either way)