Using KIO to retrive HTTP Headers [GSoC student help request]

Dawit A adawit at kde.org
Sun Jul 8 15:06:19 BST 2012


On Sun, Jul 8, 2012 at 4:29 AM, David Faure <faure at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20120708/4bf8d6ff/attachment.htm>


More information about the kfm-devel mailing list