Class

HttpClient

HttpClient()

Constructor

# new HttpClient()

This class provides functionality to download files from HTTPS URLs. It uses Node.js built-in https module to make requests.

A simple HTTP client for downloading files.

View Source utils/http.ts, line 4

Methods

# async static downloadFile(url)

This method sends a GET request to the specified URL and returns the response body as a string. It handles different scenarios such as non-200 status codes and network errors.

Downloads a file from a given URL.

sequenceDiagram participant Client participant HttpClient participant HTTPS participant Server Client->>HttpClient: downloadFile(url) HttpClient->>HTTPS: get(url) HTTPS->>Server: GET request Server-->>HTTPS: Response HTTPS-->>HttpClient: Response object alt Status code is 200 loop For each data chunk HTTPS->>HttpClient: 'data' event HttpClient->>HttpClient: Accumulate data end HTTPS->>HttpClient: 'end' event HttpClient-->>Client: Resolve with data else Status code is not 200 HttpClient-->>Client: Reject with error end
Parameters:
Name Type Description
url

The URL of the file to download.

View Source utils/http.ts, line 106

A promise that resolves with the file content as a string.