[Interest] Proxy Ports and GET requests

Thiago Macieira thiago.macieira at intel.com
Mon Dec 15 20:36:11 CET 2014


On Monday 15 December 2014 09:52:49 Jason Kretzer wrote:
> Hello all,
> 
> I have some software that is running behind a proxy server and the policy
> there is that all HTTP/HTTPS traffic should go through the proxy port 8080.
>  
 
> The software needs to be able to perform a GET to a url to get some JSON. 
> Here is a sample of the GET code.  The url already has “setPort(8080)”
> called on it before it gets to this function.
 
> Will this work as I think it would?  I do not have access to update the
> software to test.

No. You need to update the software.

The GET request sent to a proxy server is slightly different than the GET 
request sent to the content server. You need to set the content URL in the 
request and you need to setProxy or setProxyFactory in your manager.
 
> executeGET(QUrl url)
> {
>     QNetworkReply* reply = _manager->get(QNetworkRequest(url));
>     qDebug() << "EXECUTEGET -- " << url.toDisplayString();
>     // Wait for the manager get function to finish
>     QEventLoop loop;
>     connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
>     if(!reply->isFinished())
>         loop.exec();
>     QByteArray bytearray = reply->readAll();
>     //error checking removed for brevity//
>     return QJsonDocument::fromJson(bytearray);
> }
> 
> Thanks!

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list