massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / request-light / lib / browser / main.js
1 "use strict";
2 /*---------------------------------------------------------------------------------------------
3  *  Copyright (c) Microsoft Corporation. All rights reserved.
4  *  Licensed under the MIT License. See License.txt in the project root for license information.
5  *--------------------------------------------------------------------------------------------*/
6 Object.defineProperty(exports, "__esModule", { value: true });
7 function configure(_proxyUrl, _strictSSL) {
8 }
9 exports.configure = configure;
10 async function xhr(options) {
11     const requestHeaders = new Headers(options.headers || {});
12     if (options.user && options.password) {
13         requestHeaders.set('Authorization', 'Basic ' + btoa(options.user + ":" + options.password));
14     }
15     const requestInit = {
16         method: options.type,
17         redirect: options.followRedirects > 0 ? 'follow' : 'manual',
18         mode: 'cors',
19         headers: requestHeaders
20     };
21     const requestInfo = new Request(options.url, requestInit);
22     const response = await fetch(requestInfo);
23     const resposeHeaders = {};
24     for (let name in response.headers) {
25         resposeHeaders[name] = response.headers.get(name);
26     }
27     return {
28         responseText: await response.text(),
29         status: response.status,
30         headers: resposeHeaders
31     };
32 }
33 exports.xhr = xhr;