kaven-utils
Version:
Utils for Node.js.
78 lines (77 loc) • 3.16 kB
TypeScript
/********************************************************************
* @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-10-22 15:20:06.837
* @version: 6.1.1
* @times: 247
* @lines: 793
* @copyright: Copyright © 2018-2025 Kaven. All Rights Reserved.
* @description: [description]
* @license: [license]
********************************************************************/
import { FilePath, ILoggingAgent } from "kaven-basic";
import { KavenRequestResult } from "./KavenRequestResult.js";
import { IDownloadFileOptions, 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 2025-10-14
*/
export declare function HttpTryGetText(urls: string | string[], timeout?: number, logger?: ILoggingAgent): 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 2025-10-14
*/
export declare function HttpTryGetJson<T>(urls: string | string[], timeout?: number, logger?: ILoggingAgent): 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-10-14
*/
export declare function GetExternalIp(options?: IGetExternalIpOptions): Promise<string>;
/**
* @since 1.0.9
* @version 2025-10-14
*/
export declare function DownloadFile(url: string, savePath: string, options?: IDownloadFileOptions): 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 2025-10-14
*/
export declare function GetExternalIpByUPnP(parameters?: GetExternalIpByUPnPOptions): Promise<string | undefined>;