cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.39k stars 150 forks source link

Check for missing filename directive in Content-disposition #67

Closed riyaz-ali closed 4 years ago

riyaz-ali commented 4 years ago

This PR adds an additional check in guessFilename(resp *http.Response) function to make sure that the we only read the filename from the Content-disposition header when the filename directive is supplied as it's completely legal and valid [source] for the server to just return inline or attachment directives without supplying the filename

If we can't read the name from the header we simply fallback to URL.Path for filename value.

This PR fixes #64

cavaliercoder commented 4 years ago

Excellent PR, thank you! Problem well explained, researched existing issues, fix is succinct, tests with good coverage, existing style honored. Love it.