UNPKG

kaven-utils

Version:

Utils for Node.js.

81 lines (80 loc) 3.06 kB
/******************************************************************** * @author: Kaven * @email: kaven@wuwenkai.com * @website: http://blog.kaven.xyz * @file: [Kaven-Utils] /src/KavenUtility.Net.ts * @create: 2018-08-30 11:26:09.057 * @modify: 2025-05-24 08:01:53.803 * @version: 5.5.1 * @times: 238 * @lines: 811 * @copyright: Copyright © 2018-2025 Kaven. All Rights Reserved. * @description: [description] * @license: [license] ********************************************************************/ import { FilePath } from "kaven-basic"; import { KavenRequestResult } from "./KavenRequestResult.js"; import { IExecuteSoapActionOptions, IGetExternalIpOptions } from "./base/Interfaces.js"; import { GetExternalIpByUPnPOptions } from "./base/Types.js"; /** * @since 5.4.0 * @version 2024-11-01 */ export declare function HttpGet<T = unknown>(url: string, timeout?: number): Promise<KavenRequestResult<T>>; /** * Makes an asynchronous attempt to perform a GET request to one or more URLs. * If multiple URLs are provided, it resolves with the first successful response. * @param urls - A single URL or an array of URLs to attempt the GET request. * @returns A promise that resolves with the first successful response or `undefined` if all attempts fail. * @since 5.4.0 * @version 2024-05-24 */ export declare function HttpTryGetText(urls: string | string[], timeout?: number): Promise<string | undefined>; /** * Makes an asynchronous attempt to perform a GET request to one or more URLs. * If multiple URLs are provided, it resolves with the first successful response. * @param urls - A single URL or an array of URLs to attempt the GET request. * @returns A promise that resolves with the first successful response or `undefined` if all attempts fail. * @since 5.4.0 * @version 2023-12-08 */ export declare function HttpTryGetJson<T>(urls: string | string[]): Promise<T | undefined>; /** * @since 1.1.23 * @version 2025-05-22 */ export declare function HttpPost<T = unknown>(url: string, data: unknown): Promise<KavenRequestResult<T>>; /** * @since 1.0.9 * @version 2025-05-24 */ export declare function GetExternalIp(options?: IGetExternalIpOptions): Promise<string>; /** * * @param url * @param savePath * @version 1.0.0 * @since 1.0.9 */ export declare function DownloadFile(url: string, savePath: string): Promise<string>; /** * * @param url * @param options * @param tryDetectFileTypeByMagicNumber * @param minSizeInBytes * @since 4.0.0 * @version 2022-04-09 * @returns */ export declare function HttpDownload(url: string, options: FilePath, tryDetectFileTypeByMagicNumber?: boolean, minSizeInBytes?: number): Promise<FilePath>; /** * @since 5.0.4 * @version 2023-11-25 */ export declare function ExecuteSoapAction(options: IExecuteSoapActionOptions): Promise<string | undefined>; /** * @since 5.0.3 * @version 2023-12-08 */ export declare function GetExternalIpByUPnP(parameters?: GetExternalIpByUPnPOptions): Promise<string | undefined>;