Support Conditional GET

Bug #1288905 reported by Stuart Langridge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-download-manager (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

It is possible to pass If-Modified-Since and ETag headers to an HTTP GET request; if the server believes that the file has not changed from the last download (where you got the Last-Modified and ETag data) then it will return a 304 Not Modified response.

Ideally, therefore, it would be possible to do this with the Download Manager. That is, from QML, I do

downloadmanager.download("http://example.org/somefile.txt")

and when that request completes I get the path of the downloaded file, but I also get the ETag and Last-Modified that the server supplied. I can then cache that ETag and Last-Modified. Later, I want to download that file again, *only if it's changed on the server*. So I call

downloadmanager.download("http://example.org/somefile.txt", {ETag: myCachedETag, LastModified: myCachedLastModified});

The DLM sees that I supplied an etag and lastmodified, so it adds ETag and If-Modified-Since headers to the GET request. It also works out where it would download that file to, and looks to see if a file already exists at that path. If a file exists at that path, and the server returns 304 Not Modified to the HTTP request, then the DLM says "aha, the file hasn't changed, and there is already a download for this, so I shall assume that the file on disk is the file that I would have downloaded", and it returns *the existing file path* as the path of the download.

If my app edits the file on disk, it is my app's responsibility to invalidate its cached ETag and LastModified values. If my app does not do that, then the DLM will not download a newer version of the file, but that's my own fault.

Note that if I've deleted the file on disk, the DLM should ignore any passed etag/lastmodified data, because there's no disk file.

This requires the DLM to make the ETag and Last Modified values from the response headers available to the calling app when a download completes.

(For extra thought: perhaps if I pass ETag and LastModified I should also pass a file path of the file on disk? The DLM doesn't *read* that file, but it checks that it exists. That way we don't get problems with "file (1).txt" and so on.)

Stuart Langridge (sil)
description: updated
Revision history for this message
Stuart Langridge (sil) wrote :
Changed in ubuntu-download-manager:
status: New → Triaged
importance: Undecided → Wishlist
assignee: nobody → Manuel de la Peña (mandel)
Changed in ubuntu-download-manager (Ubuntu):
status: New → Triaged
importance: Undecided → Wishlist
no longer affects: ubuntu-download-manager
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.