feat: Set User-agent header when requesting schema over HTTP(S)#1226
Open
svifred wants to merge 2 commits intoredhat-developer:mainfrom
Open
feat: Set User-agent header when requesting schema over HTTP(S)#1226svifred wants to merge 2 commits intoredhat-developer:mainfrom
svifred wants to merge 2 commits intoredhat-developer:mainfrom
Conversation
Include a well-formed RFC 9110-compliant User-Agent on all direct xhr calls when fetching schemas over HTTP or HTTPS: yaml-language-server/<version> (RedHat) node/<nodeVersion> (<platform>) The server version is read from YAML_LANGUAGE_SERVER_VERSION, the Node.js version from process.versions.node, and the platform from process.platform. All three are guarded with typeof-process checks for browser/web worker safety, falling back to 'unknown' for the version and omitting the runtime and platform tokens entirely in non-Node environments.
Cover version from env var, 'unknown' fallback, http:// parity, Accept-Encoding preservation, successful response handling, and xhr error rejection.
Contributor
|
This seems like it would be pretty helpful. Do you have an example of a schema behind a CDN that rejects requests without a |
Author
I'll see what I can dig up without referencing enterprise internal infrastructure. Stay tuned! |
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.
What does this PR do?
Some CDNs block requests, when
User-agentheader is unset. This PR adds theUser-agentheader til HTTP(S) requests for schemas.What issues does this PR fix or reference?
No issue in GitHub, but problem has been spotted "in the wild", where CloudFlare challenges requests for schemas in VS Code.
Is it tested? How?
Only tested in unit tests.
Note on AI assistance
Extensive AI assistance was used to create this PR, specifically Claude Sonnet 4.6 using OpenCode.