4

You may say it will look at Content-Disposition for file name, but I'm talking about where there's nothing in that header and also URL is not so straight forward like http://website.com/myfile.zip. I leave some examples here but wondering how browser (I use FireFox) find out the right name in save as dialog. Does it know the URL syntax for famous websites ?

download links in sourceforge.net
download links in cnet.com
download from your own localhost

I used Fiddler2 for reverse engineering.

URL: http://mesh.dl.sourceforge.net/project/npp-plugins/Function List/FunctionList Plugin v2.1/FunctionList_2_1_UNI_dll.zip

Fiddler output sample:

HTTP/1.1 200 OK
Date: Sat, 13 Nov 2010 22:46:31 GMT
Server: Apache/2.2.9 (Debian)
Last-Modified: Thu, 18 Feb 2010 04:35:26 GMT
ETag: "142a602c-1fe24-47fd87eed7f80"
Accept-Ranges: bytes
Content-Length: 130596
Connection: close
Content-Type: application/zip

EDIT: Problem is Content-Disposition is not set at final response, instead it at one of redirection. HttpWebRespose header contains last response header (AllowAutoRedirect = true). I need to keep track of all responses and check if there is a Content-Disposition then remember it. How ?

1
  • 1
    No, browsers developers don't use to make special code for "famous" websites. Commented Nov 13, 2010 at 22:29

2 Answers 2

7

The do use content-disposition or any other standard method. See this example I just get from SourceForge using Live HTTP Headers:

HTTP/1.1 302 Found
X-Powered-By: PHP/5.2.9
Content-Disposition: attachment; filename="FunctionList_2_1_UNI_dll.zip"
Location: http://mesh.dl.sourceforge.net/project/npp-plugins/Function%20List/FunctionList%20Plugin%20v2.1/FunctionList_2_1_UNI_dll.zip
Content-Type: text/html
Content-Length: 0
Date: Sat, 13 Nov 2010 22:30:00 GMT
Server: lighttpd/1.4.26

Note that they also use a redirect, maybe you get confused by that.

0
0

If its not the filename attribute of the Content-Disposition header, its likely some HTTP 302 redirect, or a hidden iframe with the file download.

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.