0

In downloading a file (Eclipse's win32 zip) from the following URL in Firefox, the filename is known to be eclipse-jee-juno-SR1-win32.zip.

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/juno/SR1/eclipse-jee-juno-SR1-win32.zip&url=http://download.eclipse.org/technology/epp/downloads/release/juno/SR1/eclipse-jee-juno-SR1-win32.zip&mirror_id=1

However, this file name is not specified in the Content-disposition header, which is the standard method of acquiring the server-suggested file name.

Here, eclipse's download is simply an example. I see that the file name is a part of the URL, but is there an alternative method to get the file name? I could use regex to extract the file name from the URL in this case, but it isn't guaranteed to be a part of every URL without a Content-disposition header.

Question: How can the download's file name be acquired when no Content-disposition header is present? Or, more localized, how does Firefox come up with the aforementioned name?

Or is Firefox simply parsing the URL here, and I've come across a case where it simply happens to work despite extracting the file name from an indirect, script-delivered download?

1 Answer 1

1

Content Disposition is the standard method for the server to suggest a file name. In the absence of a content disposition header, it's entirely up to the client to come up with a file name. The most common option is to take the last segment of the path.

In the absence of a content disposition header, the server isn't even really saying that the url should be downloaded to a file rather than displayed. It's just that most browsers default to saving as a file anything they cannot display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.