Http request with QNetworkRequest placing resolved ip address in HTTP host header not domain
-
wrote on 24 Feb 2018, 00:35 last edited by
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?wrote on 26 Feb 2018, 17:18 last edited by jasonparallel@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
-
wrote on 26 Feb 2018, 17:47 last edited by
What version of Qt are you using?
-
wrote on 26 Feb 2018, 17:58 last edited by
Version 4.8
-
wrote on 26 Feb 2018, 18:55 last edited by
7 years old and unsupported so might be a minor bug that was since resolved (I haven't tested Qt 5.10)
-
7 years old and unsupported so might be a minor bug that was since resolved (I haven't tested Qt 5.10)
wrote on 26 Feb 2018, 20:30 last edited by@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
wrote on 26 Feb 2018, 20:32 last edited byIf you provide a minimal example (using a public proxy) I can test if the current version is still affected
-
wrote on 27 Feb 2018, 03:01 last edited by
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.
wrote on 27 Feb 2018, 16:13 last edited byIt is also only for https (http sends the hostname either way)
10/10