For the longest time, I always wondered how WordPress.org always served the current version of wordpress from a file named “latest.tar.gz”, and whenever I downloaded it with a browser (such as Firefox), my browser would always save it as something like “wordpress-3.5.2.tar.gz” instead. This never happened when I would retrieve the file using “wget”. I never really bothered looking into it much.
Just tonight I stumbled across it while downloading a driver for a USB wireless adapter that I have.
It’s all in the “Content-Disposition” header, which can contain an optional “filename” field tagged on to the end. The “filename” field is just a suggestion to the browser for a filename to save the file as. It’s not mandatory, and apparently “wget” doesn’t give a hoot about it. Well, I don’t like my packages having filenames like “dl.php”, so I dug in a bit and learned what made this happen.
(I need to rename “dl.php” to something else, and I wanted to find the suggested filename.)
Here’s a sample of what the Content-Disposition HTTP response header may look like when downloading a file with a suggested filename:
Content-Disposition: attachment;filename=Package-2013_07_08.dmg