2010-11-13 148 views
2

你可能會說它會查看Content-Disposition作爲文件名,但我正在談論這個標題中什麼都沒有,並且URL也不是那麼直截了當,如http://website.com/myfile.zip。我在這裏留下一些例子,但想知道如何瀏覽器(我使用FireFox)在save as dialog找到正確的名稱。它是否知道着名網站的URL語法?瀏覽器如何在下載中找到文件名?

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

我用Fiddler2進行逆向工程。

URL:http://mesh.dl.sourceforge.net/project/npp-plugins/Function列表/ FunctionList插件V2.1/FunctionList_2_1_UNI_dll.zip

的Fiddler輸出樣本:

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:問題是Content-Disposition沒有被設置爲最終響應,而不是在它的一個重定向。 HttpWebRespose標題包含最後response headerAllowAutoRedirec t = true)。我需要跟蹤所有回覆,並檢查是否存在Content-Disposition然後記住它。怎麼樣 ?

+1

不,瀏覽器開發人員不使用爲「着名」網站製作特殊代碼。 – 2010-11-13 22:29:01

回答

5

使用content-disposition或任何其他標準的方法。請參閱使用Live HTTP Headers這個例子我剛剛從SourceForge得到:

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 

注意,他們也使用重定向,也許你會受到該混淆。

0

如果它不是Content-Disposition標題的文件名屬性,它可能包含一些HTTP 302重定向,或者帶有文件下載的隱藏iframe

相關問題