@prostory/mountain
Version:
Yet another HTTP/2 server and client.
24 lines (23 loc) • 1.14 kB
TypeScript
/// <reference types="node" />
import { SecureClientSessionOptions, ClientSessionRequestOptions } from 'http2';
import { Http2SessionEventMap, Response } from './types';
export interface ClientHttp2SessionEventMap extends Http2SessionEventMap {
altsvc: (alt: string, origin: string, streamId: number) => void;
origin: (origins: Array<string>) => void;
}
export interface Client {
readonly closed: boolean;
body: (chunk: string) => Client;
header: (name: string, value: string) => Client;
/** Removes headers and body from previous request. */
fresh: () => Client;
/**
* Makes a request to remote peer on opened connection.
* By default it performs **GET** request to _path_ URL.
*/
request: (path: string, options?: ClientSessionRequestOptions) => Promise<Response>;
/** Closes connection with remote peer. */
close: (callback?: VoidFunction) => void;
on: <T extends keyof ClientHttp2SessionEventMap>(event: T, listener: ClientHttp2SessionEventMap[T]) => Client;
}
export declare const client: (authority: string | URL, options?: SecureClientSessionOptions | undefined) => Client;