[webkit-qt] Handling downloads with QtWebKit

Allan Sandfeld Jensen kde at carewolf.com
Mon Nov 17 00:53:23 PST 2014


On Sunday 16 November 2014, Florian Bruhin wrote:
> Hi,
> 
> I'm searching for some howto or example on how to handle downloads
> with QtWebkit correctly, especially the unsupportedContent signal.
> 
> My main problem is what to do with the open QNetworkReply while asking
> the user for a filename to save the file to. I've looked into some
> existing projects using QtWebKit and I've seen these approaches so
> far:
> 
> - Just downloading to RAM (i.e. the default Qt behaviour, ignoring
>   readRead with no buffer size set) -> RAM could fill up rather fast.
>   I have a 250 MBit connection here, so potentially a gigabyte of RAM
>   is filled if I take 30 seconds to enter a filename.
> 
> - Not downloading anything until the filename is entered -> server
>   will probably close the connection after some seconds.
> 
> - Just re-doing the request using the URL from the reply -> Could lead
>   to a lot of problems, e.g. with DRM-like "you may download this file
>   N times" sites.
> 
> - Downloading to a temporary file until the user has entered the
>   filename, then copying it over and deleting the temporary file.
> 
> The last approach seems to be the cleanest to me, and this seems to be
> what Firefox/Chrome do as well. I've seen the Otter browser[1] doing
> this, but not anything else yet.
> 
> Am I on the right track? Is there some documentation about how to do
> this the right way anywhere?
> 
The correct way is to suspend the TCP connection until you know where to save. 
If the server closes the connection it is doing it wrong, and what we are 
talking about is a wor- around, but if it does close, you can usually just 
rerequest, can't you?

`Allan


More information about the webkit-qt mailing list