import { Buffer } from 'buffer';
import * as tls from 'tls';
import type * as net from 'net';
import * as _ from 'lodash';
import { ErrorLike } from '@httptoolkit/util';
import { Headers, RawHeaders } from '../types';
import { DnsLookupFunction } from '../util/dns';
import { CallbackRequestResult, CallbackResponseMessageResult } from './requests/request-step-definitions';
import { CADefinition, PassThroughInitialTransforms, PassThroughLookupOptions } from './passthrough-handling-definitions';
export declare function getUpstreamTlsOptions({ hostname, port, ignoreHostHttpsErrors, clientCertificateHostMap, trustedCAs }: {
    hostname: string;
    port: number;
    ignoreHostHttpsErrors: string[] | boolean;
    clientCertificateHostMap: {
        [host: string]: {
            pfx: Buffer;
            passphrase?: string;
        };
    };
    trustedCAs: Array<string> | undefined;
}): tls.ConnectionOptions;
export declare function getTrustedCAs(trustedCAs: Array<CADefinition> | undefined, additionalTrustedCAs: Array<CADefinition> | undefined): Promise<Array<string> | undefined>;
/**
 * Takes a callback result and some headers, and returns a ready to send body, using the headers
 * (and potentially modifying them) to match the content type & encoding.
 */
export declare function buildOverriddenBody(callbackResult: CallbackRequestResult | CallbackResponseMessageResult | void, headers: Headers): Promise<Uint8Array | Buffer | undefined>;
/**
 * Effectively match the slightly-different-context logic in MockttpServer for generating a 'name'
 * for a request's destination (e.g. in the URL). We prioritise domain names over IPs, and
 * derive the most appropriate name available. In this method we consider only hostnames, so we
 * drop the port, as that's always specified elsewhere.
 */
export declare function getEffectiveHostname(destinationHostname: string | null, socket: net.Socket, rawHeaders: RawHeaders): string;
export declare function applyDestinationTransforms(transform: PassThroughInitialTransforms & {
    setProtocol?: string;
}, { isH2Downstream, rawHeaders, port, protocol, hostname, pathname, query }: {
    isH2Downstream: boolean;
    rawHeaders: RawHeaders;
    port: string | null;
    protocol: string | null;
    hostname: string;
    pathname: string | null;
    query: string | null;
}): {
    reqUrl: string;
    protocol: string | null;
    hostname: string;
    port: string | null;
    pathname: string | null;
    query: string | null;
    rawHeaders: RawHeaders;
};
/**
 * Autocorrect the host header only in the case that if you didn't explicitly
 * override it yourself for some reason (e.g. if you're testing bad behaviour).
 */
export declare function getHostAfterModification(reqUrl: string, originalHeaders: Headers, replacementHeaders: Headers | undefined): string;
export declare const MODIFIABLE_PSEUDOHEADERS: readonly [":authority", ":scheme"];
/**
 * Automatically update the :scheme and :authority headers to match the updated URL,
 * as long as they weren't explicitly overriden themselves, in which case let them
 * be set to any invalid value you like (e.g. to send a request to one server but
 * pretend it was sent to another).
 */
export declare function getH2HeadersAfterModification(reqUrl: string, originalHeaders: Headers, replacementHeaders: Headers | undefined): {
    [K in typeof MODIFIABLE_PSEUDOHEADERS[number]]: string;
};
export declare function getRequestContentLengthAfterModification(body: string | Uint8Array | Buffer, originalHeaders: Headers | RawHeaders, replacementHeaders: Headers | RawHeaders | undefined, context: {
    httpVersion: 1 | 2;
}): string | undefined;
export declare function getResponseContentLengthAfterModification(body: string | Uint8Array | Buffer, originalHeaders: Headers | RawHeaders, replacementHeaders: Headers | RawHeaders | undefined, context: {
    httpMethod: string;
    httpVersion: 1 | 2;
}): string | undefined;
export declare const getDnsLookupFunction: ((lookupOptions: PassThroughLookupOptions | undefined) => DnsLookupFunction) & _.MemoizedFunction;
export declare function getClientRelativeHostname(hostname: string, remoteIp: string | undefined, lookupFn: DnsLookupFunction): Promise<string>;
export declare function buildUpstreamErrorTags(e: ErrorLike): string[];
//# sourceMappingURL=passthrough-handling.d.ts.map