-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[py] refactor HtmlOnlyHandler in webserver.py to support JSON content #14705
[py] refactor HtmlOnlyHandler in webserver.py to support JSON content #14705
Conversation
to support various content types and CORS origin. also re-wrote the `do_POST` method for efficiency
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There seems to be quite a bit of code duplication between the new code and the existing code. Let's refactor it |
@AutomatedTester Initially, I tried to modify the What do you suggest? Having 2 handlers or just one? |
Refactored the code into one class to handle JSON type |
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
The current
HtmlOnlyHandler
does not takes into account various other content types like JSON and results into errors.This PR add a new
ExtendedHandler
that can help with these types and also enable CORS for GET, POST methods.Motivation
I was trying out FedCM implementation for python and cannot get the POST methods to work with the
SimpleWebServer()
due to CORS origin errors and JSON type not supported in the earlierHtmlOnlyHandler
. The addedExtendedHandler
will help with running the FedCM tests.Types of changes
Checklist
PR Type
enhancement
Description
HtmlOnlyHandler
withExtendedHandler
to handle various content types including JSON.do_GET
method to dynamically serve HTML pages and support different file types based on extensions.do_POST
method for better clarity and efficiency, including improved handling of file uploads.Changes walkthrough 📝
webserver.py
Enhance HTTP handler to support JSON and CORS
py/test/selenium/webdriver/common/webserver.py
HtmlOnlyHandler
withExtendedHandler
to support more contenttypes.
do_GET
method to serve JSON and other file types.do_POST
method for improved clarity and efficiency.