Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$.download() cannot detect file name in case of redirect #2690

Closed
asolntsev opened this issue Mar 20, 2024 · 0 comments · Fixed by #2692
Closed

$.download() cannot detect file name in case of redirect #2690

asolntsev opened this issue Mar 20, 2024 · 0 comments · Fixed by #2692
Assignees
Milestone

Comments

@asolntsev
Copy link
Member

The problem

Given a link that redirects and downloads a file:
<a href="https://my.com/Jaxbeja">Download report</a>

  1. The link "https://my.com/Jaxbeja" redirects to "https://my.com/site-upload/03/c9/2363/report_20032024.pdf"
  2. The former link causes file downloading.
  3. Chrome downloads a file named "report_20032024.pdf"
  4. BUT Selenide downloads a file named "Jaxbeja".

Tell us about your environment

  • Selenide Version: 7.2.1
  • Configuration.fileDownload: HTTPGET

Implementation details

  • Selenide uses Apache HttpClient5 for performing request GET "https://my.com/Jaxbeja"
  • BUT this library doesn't return the second url in any way in response. So Selenide cannot know the file name.
@asolntsev asolntsev added this to the 7.2.2 milestone Mar 20, 2024
@asolntsev asolntsev self-assigned this Mar 20, 2024
asolntsev added a commit that referenced this issue Mar 21, 2024
…Content-Disposition")

Currently, it fails for HTTPGET method.
asolntsev added a commit that referenced this issue Mar 21, 2024
…redirect (without header "Content-Disposition")

Fixed for HTTPGET method: now we detect URL of a last redirect, and extract filename from this URL.
@asolntsev asolntsev linked a pull request Mar 21, 2024 that will close this issue
asolntsev added a commit that referenced this issue Mar 21, 2024
* avoid using FilenameUtils.getExtension() because it throws "IllegalArgumentException: NTFS ADS separator (':') in file name is forbidden" - we don't need this check. Some of our tests do have filenames with forbidden characters.
* instead, extract file extension with a simple regex.
asolntsev added a commit that referenced this issue Mar 21, 2024
…Content-Disposition")

Currently, it fails for HTTPGET method.
asolntsev added a commit that referenced this issue Mar 21, 2024
…redirect (without header "Content-Disposition")

Fixed for HTTPGET method: now we detect URL of a last redirect, and extract filename from this URL.
asolntsev added a commit that referenced this issue Mar 21, 2024
* avoid using FilenameUtils.getExtension() because it throws "IllegalArgumentException: NTFS ADS separator (':') in file name is forbidden" - we don't need this check. Some of our tests do have filenames with forbidden characters.
* instead, extract file extension with a simple regex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant