Enhance User-Agent header handling in BrowserSession#4431
Merged
Conversation
- Updated the BrowserSession class to ensure the User-Agent header is set correctly for both local and remote connections. - Introduced a utility function to retrieve the browser-use version and incorporated it into the User-Agent string. - Ensured headers are consistently handled as dictionaries to avoid potential issues with None values. This change improves the reliability of the CDP client communication by providing a proper User-Agent, which can be crucial for certain web interactions.
Agent Task Evaluation Results: 2/2 (100%)View detailed results
Check the evaluate-tasks job for detailed task execution logs. |
- Improved assertions in tests to ensure all user-provided headers are present in the additional_headers. - Added checks to confirm that the User-Agent header is injected for remote connections, ensuring consistent behavior across tests. - Updated the test for the /json/version endpoint to validate the presence and format of the User-Agent header. These changes enhance the reliability of header handling in the CDP client tests.
- Updated the assertion for the User-Agent header in the /json/version endpoint test to improve readability by using a multi-line format. - This change enhances the clarity of the test's intent while maintaining the existing validation logic. These modifications contribute to better maintainability of the test code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change improves the reliability of the CDP client communication by providing a proper User-Agent, which can be crucial for certain web interactions.
Summary by cubic
Ensure
BrowserSessionalways sends a proper User-Agent and preserves user headers. Injects defaultbrowser-use/<version>for remote CDP and/json/versionrequests to improve version discovery and WebSocket stability.browser-use/<version>for/json/versionand remote CDP; preserve all user headers and any existing User-Agent.Noneonly for local when empty; always include User-Agent for remote, even with no user headers.Written for commit ad41865. Summary will update on new commits.