import http from 'http'; import { Headers, IncomingMessageWithBody, ResponseBody, ResponseTuple, UploadxResponse } from '../types'; export declare const typeis: { (req: http.IncomingMessage, types: string[]): string | false; is(mime: string, types?: string[]): string | false; hasBody(req: http.IncomingMessage): number | false; }; /** * Reads the body from the request. * @param req - request object * @param encoding - encoding to use * @param limit - optional limit on the size of the body */ export declare function readBody(req: http.IncomingMessage, encoding?: BufferEncoding, limit?: number): Promise; /** * Reads the body of the incoming metadata request and parses it as JSON. * @param req - incoming metadata request * @param limit - optional limit on the size of the body */ export declare function getJsonBody(req: IncomingMessageWithBody>, limit?: number): Promise>; /** * Retrieve the value of a specific header of an HTTP request. * @param req - request object * @param name - name of the header * @param all - if true, returns all values of the header, comma-separated, otherwise returns the last value. */ export declare function getHeader(req: http.IncomingMessage, name: string, all?: boolean): string; /** * Appends value to the end of the multi-value header */ export declare function appendHeader(res: http.ServerResponse, name: string, value: http.OutgoingHttpHeader): void; /** * Sets the value of a specific header of an HTTP response. */ export declare function setHeaders(res: http.ServerResponse, headers?: Headers): void; /** * Try build a protocol:hostname:port string from a request object. */ export declare function getBaseUrl(req: http.IncomingMessage): string; /** * Extracts host with port from a http or https request. */ export declare function extractHost(req: http.IncomingMessage & { host?: string; hostname?: string; }): string; /** * Extracts protocol from a http or https request. */ export declare function extractProto(req: http.IncomingMessage): string; export declare function responseToTuple(response: UploadxResponse | ResponseTuple): ResponseTuple; export declare function tupleToResponse(response: ResponseTuple | UploadxResponse): UploadxResponse; export declare function normalizeHookResponse(fn: (file: T) => Promise): (file: T) => Promise<{ statusCode: number | undefined; headers: Headers | undefined; body: ResponseBody; } | { body: never; statusCode?: undefined; headers?: undefined; }>;