Page MenuHomePhabricator

Download sometimes named index.php instead of collection.pdf (due to slow sending of Content-Disposition header)
Closed, InvalidPublic

Description

Author: headbomb_v

Description:
Often, but not always, when I click "save link as", it saves the file as index.php rather than "collection.pdf"

This is rather annoying, as i now have to click the file, wait for it to load, then go in Firefox > File > Save Page As, and then I can save it as a PDF.

It seem happen on the bigger collections more often than the smaller ones. I don't know if this is a coincidence or not.


OS: Windows 7
Platform: PC

Details

Reference
bz27624

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:28 PM
bzimport added a project: Collection.
bzimport set Reference to bz27624.
bzimport added a subscriber: Unknown Object (MLST).

Presumably the Content-Disposition header is not used when the file has not finished downloading. This could be fixed by putting "collection.pdf" at the end of the path section of the URL, as a fake subpage of [[Special:Book]].

Works every time for me... @tstarling, can you clarify what you meant here? Are we offering the file for download before it's actually ready?

It's reproducible in Firefox 38.

http://tstarling.com/stuff/slow-content-disposition.php

This script provides a link, and when you request the linked URL, the script sleeps for 10 seconds before sending a Content-Disposition header. When you right-click the link and select "save link as", Firefox waits for the headers for about 5 seconds, then gives up and uses the script filename instead.

I tested IE also, it waits for the whole 10 seconds for the headers to arrive, so the issue does not affect it.

The theory being that if you're on satellite or if our servers are slow or something, then PDF downloads may randomly hit Firefox's 5 second timeout and thus ignore the Content-Disposition header.

Krinkle renamed this task from Saves as index.php instead of collection.pdf to Download sometimes named index.php instead of collection.pdf.May 17 2015, 11:42 PM
Krinkle updated the task description. (Show Details)
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).

That's... interesting behaviour from Firefox. I reproduced it in Firefox 38 but not Chrome 44 with this script:

<?php
if ( isset( $_GET["download"] ) ) {
        header( "Content-Disposition: inline; filename=foo.bar" );
        sleep( 10 );
}
echo "<a href=\"?download=1\">Click here</a>";
?>

Can we make it send headers immediately? Perhaps via flush() or equivalent? That appears to resolve the issue in this code.

Aklapper renamed this task from Download sometimes named index.php instead of collection.pdf to Download sometimes named index.php instead of collection.pdf (due to slow sending of Content-Disposition header).Dec 21 2016, 10:48 AM
Aklapper lowered the priority of this task from Medium to Low.
Pppery subscribed.

Closing as obsolete - Collection PDF export functionality has been dead for years.