Get the answering IP from QNetworkReply

262 Views Asked by At

Good morning,

I am doing some get requests using QNetworkAccessManager from Qt5.12. When I create the QNetworkRequest, I use a url containing a hostname. I would like to know the exact IP of the server that is answering (since the hostname can be bound to many addresses, and the addresses change).

I could not find anything in QNetworkReply that I get (maybe is the wrong class to analyse? I am not sure)

Someone knows where to get that information?

UPDATE:

As state in the comments, the "hack" I found (since Qt5.13) is:

  • resolve the hostname by myself (and print it)
  • use the IP to send the request
  • use setPeerVerifyName in the request with the hostname for the certificate validation

But what I would really like is an API like the following, once I have the QNetworkReply (and I received the "finished" signal)

if ( http_code != HTTP_OK )
{
    print network_reply.getIp()
}
0

There are 0 best solutions below