set a user agent when attempting to retrieve $schema JSON Schemas (#190726)

This commit is contained in:
Martin Aeschlimann 2023-08-21 12:14:11 +02:00 committed by GitHub
parent 829932cb62
commit 69b2435e14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, OutputChannel, window, workspace, l10n } from 'vscode';
import { ExtensionContext, OutputChannel, window, workspace, l10n, env } from 'vscode';
import { startClient, LanguageClientConstructor, SchemaRequestService, languageServerDescription } from '../jsonClient';
import { ServerOptions, TransportKind, LanguageClientOptions, LanguageClient, BaseLanguageClient } from 'vscode-languageclient/node';
@ -129,7 +129,10 @@ async function getSchemaRequestService(context: ExtensionContext, log: Log): Pro
const isXHRResponse = (error: any): error is XHRResponse => typeof error?.status === 'number';
const request = async (uri: string, etag?: string): Promise<string> => {
const headers: Headers = { 'Accept-Encoding': 'gzip, deflate' };
const headers: Headers = {
'Accept-Encoding': 'gzip, deflate',
'User-Agent': `${env.appName} (${env.appHost})`
};
if (etag) {
headers['If-None-Match'] = etag;
}