node-libcurl
Version:
The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl
63 lines • 2.09 kB
TypeScript
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { CurlOptionValueType } from './generated/CurlOption';
import { HeaderInfo } from './parseHeaders';
/**
* Object the curly call resolves to.
*
* @public
*/
export interface CurlyResult {
/**
* Data will be the body of the requested URL
*/
data: string;
/**
* Parsed headers
*
* See {@link HeaderInfo}
*/
headers: HeaderInfo[];
/**
* HTTP Status code for the last request
*/
statusCode: number;
}
declare const methods: readonly ["acl", "bind", "checkout", "connect", "copy", "delete", "get", "head", "link", "lock", "m-search", "merge", "mkactivity", "mkcalendar", "mkcol", "move", "notify", "options", "patch", "post", "propfind", "proppatch", "purge", "put", "rebind", "report", "search", "source", "subscribe", "trace", "unbind", "unlink", "unlock", "unsubscribe"];
declare type HttpMethod = typeof methods[number];
interface CurlyHttpMethodCall {
/**
* **EXPERIMENTAL** This API can change between minor releases
*
* Async wrapper around the Curl class.
*
* The `curly.<field>` being used will be the HTTP verb sent.
*/
(url: string, options?: CurlOptionValueType): Promise<CurlyResult>;
}
declare type HttpMethodCalls = {
[K in HttpMethod]: CurlyHttpMethodCall;
};
export interface CurlyFunction extends HttpMethodCalls {
/**
* **EXPERIMENTAL** This API can change between minor releases
*
* Async wrapper around the Curl class
* It's also possible to request using a specific http verb
* directly by using `curl.<http-verb>(url)`
*/
(url: string, options?: CurlOptionValueType): Promise<CurlyResult>;
create: () => CurlyFunction;
}
/**
* Curly function
*
* @public
*/
export declare const curly: CurlyFunction;
export {};
//# sourceMappingURL=curly.d.ts.map