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

Thiago Macieira thiago.macieira at intel.com
Sun Jun 8 06:48:01 CEST 2014


Em dom 08 jun 2014, às 06:05:20, Nikos Chantziaras escreveu:
> It fails even without the redirection. I only used "sf.net" instead of
> "sourceforge.net" in order to make the code smaller for posting here. So
> this will also fail:
> 
>    QNetworkRequest request(QUrl("http://qtads.sourceforge.net/COPYING"));

I can reproduce it here. Traffic sniffing and strace reveal it's a server bug. The 
server closed the connection.

[pid 93870] write(8, "GET /COPYING HTTP/1.1\r\nConnection: Keep-
Alive\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: pt-BR,en,*\
r\nUser-Agent: Mozilla/5.0\r\nHost: qtads.sourceforge.net\r\n\r\n", 164) = 164
[pid 93870] poll([{fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 2, 
4294967295) = 1 ([{fd=8, revents=POLLIN|POLLERR|POLLHUP}])

[pid 93870] ioctl(8, FIONREAD, [0])     = 0

[pid 93870] read(8, 0x7f120211b707, 1)  = -1 ECONNRESET (Connection reset by 
peer)

21:44:24.901771 IP 10.0.0.4.49374 > 216.34.181.96.80: Flags [P.], seq 1:165, 
ack 1, win 29200, options [nop,nop,TS val 161847230 ecr 2043326185], length 
164
21:44:24.974463 IP 216.34.181.96.80 > 10.0.0.4.49374: Flags [.], ack 165, win 
4544, options [nop,nop,TS val 2043326259 ecr 161847230], length 0
21:44:24.975365 IP 216.34.181.96.80 > 10.0.0.4.49374: Flags [R.], seq 1, ack 
165, win 4544, length 0

Since it closes the connection right after the request is sent, the problem 
must be triggered by one of the headers. It can't be Accept-Language because I 
doubt you have the same settings as I do. It can't be the Connection header 
because it would cause problems for browsers everywhere. So it has to be 
Accept-Encoding or the User-Agent.

I found it in the first try:
$ curl -A Mozilla/5.0 http://qtads.sourceforge.net/COPYING
curl: (56) Recv failure: Connection reset by peer

Like I said, server bug.

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




More information about the Interest mailing list