UNPKG

sync-request-curl

Version:

Fast way to send synchronous web requests in NodeJS. API is a subset of sync-request. Leverages node-libcurl for high performance. Cannot be used in a browser.

26 lines (25 loc) 941 B
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import { IncomingHttpHeaders } from 'http'; export type HttpVerb = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'; export type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex'; export interface Options { headers?: IncomingHttpHeaders; qs?: { [key: string]: any; }; json?: any; timeout?: number; body?: string | Buffer | NodeJS.ReadableStream; followRedirects?: boolean; maxRedirects?: number; } export type GetBody = <encoding extends BufferEncoding | undefined>(arg?: encoding) => encoding extends BufferEncoding ? string : Buffer; export interface Response { statusCode: number; headers: IncomingHttpHeaders; body: string | Buffer; getBody: GetBody; url: string; }