If you are using QNetworkAccessManager to download files from a Pure-FTPd server, the file sizes are always -1. This is cause by Qt, Pure-FTPd, and the FTP RFC spec.
Let's start from FTP RFC documentation. The very first FTP spec. is describe in RFC-959, and it doesn't describe how to retrieve size of files. The SIZE and MLSD command are describe in RFC-3659. Some FTP server may not support newer command.
For backward compatibility, QNetworkAccessManager sends HELP command first, and parse available commands to determine whether the server supports SIZE or not. But the response of HELP command is not strictly describes in RFC, so Pure-FTPd just prints a really simple help message, which doesn't mention useful command. There is a command FEAT to list all supported command, but it was appeared in RFC-2389.
For backward compatibility, QNetworkAccessManager sends HELP command first, and parse available commands to determine whether the server supports SIZE or not. But the response of HELP command is not strictly describes in RFC, so Pure-FTPd just prints a really simple help message, which doesn't mention useful command. There is a command FEAT to list all supported command, but it was appeared in RFC-2389.
For now (Qt 4.7.4), the best solution is to use QFtp. IMAO, QNetworkAccessManager is not really a general solution for both HTTP and FTP.
沒有留言:
張貼留言