amir1376 / ab-download-manager

A Download Manager that speeds up your downloads
https://abdownloadmanager.com
Apache License 2.0
3.11k stars 155 forks source link

Filenames in Response Header #204

Closed rendaa closed 1 day ago

rendaa commented 2 days ago

In some rare cases, the donwload URLs do not contain filenames. Thus, ABDM won't retrieve correct filenames.

For example the resources in this page: https://soho.komect.com/clientDownload (sorry this page is in Chinese language, just try to click these boxes with OS names, on the right side of this page)

The correct filename is contained in HTTP response headers. e.g. for the windows download: when you click the box labeled "Windows", browser sends Request Header like this:

GET /upgrade/download/app/9ebb10c5a63574f8 HTTP/1.1
Host: dl.soho.komect.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
DNT: 1
Connection: keep-alive
Referer: https://soho.komect.com/
Cookie: cna=11dd883ac31f447a80ca747f14d0b0e7
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-site
Sec-Fetch-User: ?1
Pragma: no-cache
Cache-Control: no-cache

and server responds like this:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 20 Nov 2024 13:24:50 GMT
Content-Type: application/octet-stream;charset=UTF-8
Content-Length: 318260192
Connection: keep-alive
Content-Disposition: attachment;fileName=CMCC-JTYDN-windows-2.8.7.1.exe    <-------------- Filename is here!!!
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Age: 3291
Via: https/1.1 SC03-CCS-004-CMCD-CMG ( [cSsSfU]), http/1.1 GD08-SNS-012-CMZQ-CMG ( [cHs f ])
Accept-Ranges: bytes

Hope ABDM will deal with this cleverly.

amir1376 commented 1 day ago

Hi there. thanks for reporting that. this feature is already supported but it has problem with this webserver as you can see this header

Content-Disposition: attachment;fileName=CMCC-JTYDN-windows-2.8.7.1.exe

according to the docs it should be named filename but this webserver responses with fileName

BTW I changed the check that in ignore case mode so will be fixed in next release.

Thanks again