///
///
import { IncomingHttpHeaders } from "http";
import { URLSearchParams } from "url";
import * as undici from "undici";
export type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH";
export type InlineCallbackAction = (fn: () => Promise) => Promise;
export interface ReqOptions {
/** Default: 0 */
maxRedirections?: number;
/** Default: { "user-agent": "httpie" } */
headers?: IncomingHttpHeaders;
querystring?: string | URLSearchParams;
body?: any;
authorization?: string;
agent?: undici.Agent | undici.ProxyAgent | undici.MockAgent;
limit?: InlineCallbackAction;
}
export interface RequestResponse {
data: T;
headers: IncomingHttpHeaders;
statusMessage: string;
statusCode: number;
}
/**
* @description httpie "like" request wrapper that use new Node.js http client undici under the hood.
* @see https://github.com/nodejs/undici
*
* @example
* const { statusCode, data } = await request("GET", "https://ws-dev.myunisoft.fr/ws_monitoring");
* console.log(statusCode, data); // 200 "true"
*/
export declare function request(method: HttpMethod, uri: string | URL, options?: ReqOptions): Promise>;
export type RequestCallback = (uri: string | URL, options?: ReqOptions) => Promise>;
export declare const get: RequestCallback;
export declare const post: RequestCallback;
export declare const put: RequestCallback;
export declare const del: RequestCallback;
export declare const patch: RequestCallback;