On Sun, Jul 8, 2012 at 4:29 AM, David Faure <faure@kde.org> wrote:
On Thursday 28 June 2012 06:13:15 Aish Raj Dahal wrote:
> The issue is that KIO attempts to download the entire file before
> being able to query for its HTTP header responses. This behavior may
> be taken lightly for smaller files, however for larger files
> downloading an entire file, just to get the HTTP header response
> associated with it seems to be impractical.

As Albert said, the headers are sent as soon as they are received, and the
mimetype signal is emitted before the contents of the file, this is by contract
for KIO::get(). This is how we can put the job on hold while launching the
proper application for that url, and the app then resumes the download in
order to get the file contents.


Alternatively you could use KIO::mimetype which performs an HTTP HEAD request
on the given URL, but we had the experience (many years ago) that some
webservers didn't reply correctly to HEAD requests.

The other alternative (actually a hack) you have is to connect to the KIO's mimeType signal and put the ioslave on hold as outlined in KIO::get's documentation. That should allow you to retrieve the header before downloading the file. You can then resume the download by issuing a second get request.

Dawit A.