microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
improve-package-name-resolver-test

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/node/request.ts

29lines · modeblame

a31b007cunknown10 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
3fb37ad5unknown10 years ago4import http = require("http");
f338085detatanova4 years ago5import https = require("https");
3fb37ad5unknown10 years ago6
7export class Request {
f338085detatanova4 years ago8public static request(url: string, expectStatusOK = false, isHttps = false): Promise<string> {
ce5e88eeYuri Skorokhodov5 years ago9return new Promise((resolve, reject) => {
d8f741bfEzio Li1 years ago10// CodeQL [SM04580] extension send all requests to 'localhost:port' which are built by local application
09f6024fHeniker4 years ago11const req = (isHttps ? https : http).get(url, res => {
ce5e88eeYuri Skorokhodov5 years ago12let responseString = "";
13res.on("data", (data: Buffer) => {
14responseString += data.toString();
15});
16res.on("end", () => {
17if (expectStatusOK && res.statusCode !== 200) {
18reject(new Error(responseString));
19} else {
20resolve(responseString);
21}
22});
2f10b3adunknown10 years ago23});
ce5e88eeYuri Skorokhodov5 years ago24req.on("error", (err: Error) => {
25reject(err);
2f10b3adunknown10 years ago26});
3fb37ad5unknown10 years ago27});
28}
29}