-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] Allow downloading files from old Grid server #16839
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
[java] Allow downloading files from old Grid server #16839
Conversation
Endpoint "/se/files/:name" was added in Selenium 4.39.0. If user has upgraded only Selenium client version (but not the server!) then method `remoteDriver.downloadFile()` fails with "unsupported command" exception. Now the download method will work again, falling back to the old endpoint `POST /se/files` (which is slow for large files). See issue SeleniumHQ#16612 and PR SeleniumHQ#16627.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
|
Wait, why did we add a new endpoint for this? It makes a lot more sense for file name to be in the payload instead of in the endpoint. |
Why do you prefer to put file name in the payload instead of URL? I don't understand. But the new payload was needed not because of file name. P.S. Just in case, it was already done in Selenium 4.39.0. |
|
because the name can have spaces? Plus introducing new endpoints affects all the languages, not just Java. And this isn't the convention used everywhere else? |
|
At least for this, it is an implementation detail. I think it would make more sense to provide a toggle in existing endpoint if we need different behavior? But I didn't really read through everything you did in the PR. Just introducing a new endpoint should be a big deal, though. 😂 |
No matter if it was new endpoint or new parameter/header/whatever else, it doesn't immediately affect other languages.
What convention do you mean? @titusfortner
It's doable. We can replace new "new" endpoint with a parameter/header in the old endpoint (e.g. http header |
|
Anyway, we can merge this PR and then discuss how to improve the mechanism for downloading files. |
User description
The problem
Users with
cannot download files from Grid.
🔧 Implementation Notes
Endpoint "/se/files/:name" was added in Selenium 4.39.0. If user has upgraded only Selenium client version (but not the server!) then method
remoteDriver.downloadFile()fails with "unsupported command" exception.Now the download method will work again, falling back to the old endpoint
POST /se/files(which is slow for large files).🔗 Related Issues
See issue #16612 and PR #16627.
💡 Additional Considerations
After some time, we can remove this fallback. Probably starting from Selenium 5.0.0
🔄 Types of changes
PR Type
Bug fix
Description
Add fallback to old Grid endpoint for file downloads
Support clients with newer Selenium but older Grid versions
Gracefully handle UnsupportedCommandException with warning log
Maintain backwards compatibility for file download functionality
Diagram Walkthrough
flowchart LR A["downloadFile request"] --> B{"Try new endpoint<br/>/se/files/:name"} B -->|Success| C["Stream file content"] B -->|UnsupportedCommandException| D["Log warning about<br/>old Grid version"] D --> E["Fallback to old endpoint<br/>POST /se/files"] E --> F["Unzip file contents"] C --> G["Save to target location"] F --> GFile Walkthrough
RemoteWebDriver.java
Add fallback for legacy Grid file download endpointjava/src/org/openqa/selenium/remote/RemoteWebDriver.java
endpoint fails
servers
endpoints