Skip to content

Commit b7211ec

Browse files
committed
Set a User-Agent when requesting schemas
See redhat-developer/yaml-language-server#1226 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent 3f6bb86 commit b7211ec

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/json-schema-content-provider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export async function getJsonSchemaContent(uri: string, schemaCache: IJSONSchema
4949
const httpSettings = workspace.getConfiguration('http');
5050
configureHttpRequests(httpSettings.proxy, httpSettings.proxyStrictSSL);
5151

52-
const headers: { [key: string]: string } = { 'Accept-Encoding': 'gzip, deflate' };
52+
const version = (typeof process !== 'undefined' && process.env.YAML_LANGUAGE_SERVER_VERSION) || 'unknown';
53+
const nodeVersion = typeof process !== 'undefined' && process.versions?.node ? ` node/${process.versions.node}` : '';
54+
const platform = typeof process !== 'undefined' && process.platform ? ` (${process.platform})` : '';
55+
const headers: { [key: string]: string } = {
56+
'Accept-Encoding': 'gzip, deflate',
57+
'User-Agent': `yaml-language-server/${version} (RedHat)${nodeVersion}${platform}`,
58+
};
5359
if (cachedETag) {
5460
headers['If-None-Match'] = cachedETag;
5561
}

0 commit comments

Comments
 (0)