[Interest] Can't download file with QNetworkAccessManager: "connection closed"

Reinhardt Behm rbehm at hushmail.com
Tue Jun 10 03:30:48 CEST 2014


On Monday 09 June 2014 23:26:44 Thiago Macieira wrote:
> Em seg 09 jun 2014, às 21:49:33, Nikos Chantziaras escreveu:
> > > No. Most likely, the server is trying to do something based on what
> > > browser
> > > you're using and the script crashes if you send just Mozilla/5.0.
> > 
> > Turns out they're blocking this intentionally. Their reply was:
> > 
> > "This is known and intentional. We specifically block that because of
> > abuse that has come from that user-agent (being default also means that
> > malicious behavior often uses that user-agent as well). You should set
> > the user-agent to be something that includes your project name and/or
> > URL so we know who to contact if we start to notice abusive behavior
> > from your software."
> > 
> > Perhaps Qt should add something to the user-agent string. Maybe:
> >    Mozilla/5.0 Qt/x.y.z
> 
> Given SF's reply, I'm inclined to leave it exactly as it is. If you won't
> identify your software, then SF does not want your connection and we
> shouldn't be hiding it from you

BTW: I had a similar problem with the Open Street Map tile server 
(tile.openstreetmap.org). It only worked if I set a different user agent.
My simple solution was to use the application name as the user agent:

QNetworkRequest req(tileName.arg(conf.osmServer).arg(zoom).arg(ix).arg(iy));
req.setRawHeader("user-agent", (qApp->applicationName() + " " 
  + qApp->applicationVersion()).toLatin1());
qnr = networkManager->get(req);

-- 
Best Regards

Reinhardt Behm





More information about the Interest mailing list