Bug 28466 - [GTK] When downloading a file, two GET requests are sent to the HTTP server
Summary: [GTK] When downloading a file, two GET requests are sent to the HTTP server
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Gustavo Noronha (kov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-19 12:20 PDT by Enrico Tröger
Modified: 2009-08-31 20:30 PDT (History)
2 users (show)

See Also:


Attachments
reuse connection for download (8.83 KB, patch)
2009-08-31 14:26 PDT, Gustavo Noronha (kov)
ap: review+
gustavo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrico Tröger 2009-08-19 12:20:53 PDT
When trying to download a file with WebKitGTK, it sends two HTTP GET requests to the server for some reason.

In most cases this doesn't matter, but in some cases it does indeed.

Example use case:
One-time downloads as sometimes seen on download-as-a-service offers.
The user requests a file to download, then the user gets an id or token for the download and with this token, the file can be downloaded once.
This works in Firefox 3.0 and 3.5, Arora (with the Qt Webkit port), Opera and Internet Explorer but not with WebKitGTK.

As far as I observed it, WebKitGTK sends the first request once the download link is clicked and this request is immediately cancelled. After the user chose an action to handle the download (i.e. chose a download location), the second GET request is sent. Services like the above mentioned, deliver the file already on the first GET request, the second request is then invalid as the download URL is only valid one time.

To ease testing, I set up a sample service on
http://78.31.68.117:18695/dstest.py?action=request&data=test.deb

To reproduce:
- open the above URL in a WebKitGTK browser
- then open the displayed URL in the browser
- a download is started
- check the downloaded file: it doesn't contain a Debian package but a HTTP error page because the generated URL was called twice by WebKitGTK


Tested with WebKitGTK 1.1.12, Midori (GIT) and Epiphany 2.27.90.
Comment 1 Gustavo Noronha (kov) 2009-08-21 13:33:39 PDT
I am almost sure this is caused by this:

void FrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response)
{
    // FIXME: We could reuse the same handle here, but when I tried
    // implementing that the main load would fail and stop, so I have
    // simplified this case for now.
    handle->cancel();

We should really use the handle which already exists for the download, but I could not get it to work when I tried, like I say in the comment.
Comment 2 Gustavo Noronha (kov) 2009-08-31 14:26:38 PDT
Created attachment 38834 [details]
reuse connection for download

This patch should fix this problem.
Comment 3 Enrico Tröger 2009-08-31 14:52:52 PDT
Yes, the patch seems to work. Though I tested it only with my special use case as posted in the original description.

Good job!
Comment 4 Alexey Proskuryakov 2009-08-31 16:56:14 PDT
Comment on attachment 38834 [details]
reuse connection for download

+        // us back after we release it, unless it has been replaced by someone
+        // else.

I'd just put the else on the previous line - it's not too long by WebKit standards.

r=me
Comment 5 Gustavo Noronha (kov) 2009-08-31 20:30:48 PDT
Landed as r47916.