/**
 * Node.js http module shim
 * Provides IncomingMessage, ServerResponse, and Server for virtual HTTP handling
 */
import { EventEmitter } from './events';
import { Readable, Writable, Buffer } from './stream';
import { Socket, AddressInfo } from './net';
export type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
export interface RequestOptions {
    method?: string;
    path?: string;
    headers?: Record<string, string | string[]>;
    hostname?: string;
    port?: number;
}
/**
 * Incoming HTTP request (Node.js compatible)
 */
export declare class IncomingMessage extends Readable {
    httpVersion: string;
    httpVersionMajor: number;
    httpVersionMinor: number;
    complete: boolean;
    headers: Record<string, string | string[] | undefined>;
    rawHeaders: string[];
    trailers: Record<string, string | undefined>;
    rawTrailers: string[];
    method?: string;
    url?: string;
    statusCode?: number;
    statusMessage?: string;
    socket: Socket;
    private _body;
    constructor(socket?: Socket);
    setTimeout(msecs: number, callback?: () => void): this;
    destroy(error?: Error): this;
    _setBody(body: Buffer | string | null): void;
    static fromRequest(method: string, url: string, headers: Record<string, string>, body?: Buffer | string): IncomingMessage;
}
/**
 * Outgoing HTTP response (Node.js compatible)
 */
export declare class ServerResponse extends Writable {
    statusCode: number;
    statusMessage: string;
    headersSent: boolean;
    finished: boolean;
    sendDate: boolean;
    socket: Socket | null;
    private _headers;
    private _body;
    private _resolve?;
    constructor(req: IncomingMessage);
    _setResolver(resolve: (response: ResponseData) => void): void;
    setHeader(name: string, value: string | string[] | number): this;
    getHeader(name: string): string | string[] | undefined;
    getHeaders(): Record<string, string | string[]>;
    getHeaderNames(): string[];
    hasHeader(name: string): boolean;
    removeHeader(name: string): void;
    writeHead(statusCode: number, statusMessageOrHeaders?: string | Record<string, string | string[] | number>, headers?: Record<string, string | string[] | number>): this;
    write(chunk: Uint8Array | string, encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean;
    end(chunkOrCallback?: Uint8Array | string | (() => void), encodingOrCallback?: BufferEncoding | (() => void), callback?: () => void): this;
    send(data: string | Buffer | object): this;
    json(data: unknown): this;
    status(code: number): this;
    redirect(urlOrStatus: string | number, url?: string): void;
    _getBody(): Buffer;
    _getBodyAsString(): string;
}
export interface ResponseData {
    statusCode: number;
    statusMessage: string;
    headers: Record<string, string>;
    body: Buffer;
}
/**
 * HTTP Server (Node.js compatible)
 */
export declare class Server extends EventEmitter {
    private _netServer;
    private _requestListener?;
    private _pendingRequests;
    listening: boolean;
    maxHeadersCount: number | null;
    timeout: number;
    keepAliveTimeout: number;
    headersTimeout: number;
    requestTimeout: number;
    constructor(requestListener?: RequestListener);
    listen(portOrOptions?: number | {
        port?: number;
        host?: string;
    }, hostOrCallback?: string | (() => void), callback?: () => void): this;
    close(callback?: (err?: Error) => void): this;
    address(): AddressInfo | null;
    setTimeout(msecs?: number, callback?: () => void): this;
    ref(): this;
    unref(): this;
    /**
     * Handle an incoming request (used by server bridge)
     */
    handleRequest(method: string, url: string, headers: Record<string, string>, body?: Buffer | string): Promise<ResponseData>;
}
/**
 * Create an HTTP server
 */
export declare function createServer(requestListener?: RequestListener): Server;
/**
 * HTTP status codes
 */
export declare const STATUS_CODES: Record<number, string>;
/**
 * HTTP methods
 */
export declare const METHODS: string[];
/**
 * HTTP Client Request - makes real HTTP requests using fetch()
 */
export declare class ClientRequest extends Writable {
    method: string;
    path: string;
    headers: Record<string, string>;
    private _options;
    private _protocol;
    private _bodyChunks;
    private _aborted;
    private _timeout;
    private _timeoutId;
    private _requestEnded;
    constructor(options: RequestOptions, protocol?: 'http' | 'https');
    setHeader(name: string, value: string): void;
    getHeader(name: string): string | undefined;
    removeHeader(name: string): void;
    write(chunk: Uint8Array | string, encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean;
    end(dataOrCallback?: Uint8Array | string | (() => void), encodingOrCallback?: BufferEncoding | (() => void), callback?: () => void): this;
    abort(): void;
    setTimeout(ms: number, callback?: () => void): this;
    private _performRequest;
    private _responseToIncomingMessage;
}
/**
 * Create an HTTP client request
 */
export declare function request(urlOrOptions: string | URL | RequestOptions, optionsOrCallback?: RequestOptions | ((res: IncomingMessage) => void), callback?: (res: IncomingMessage) => void): ClientRequest;
/**
 * Make an HTTP GET request
 */
export declare function get(urlOrOptions: string | URL | RequestOptions, optionsOrCallback?: RequestOptions | ((res: IncomingMessage) => void), callback?: (res: IncomingMessage) => void): ClientRequest;
/**
 * Internal: create client request with specified protocol
 * Used by https module
 */
export declare function _createClientRequest(urlOrOptions: string | URL | RequestOptions, optionsOrCallback: RequestOptions | ((res: IncomingMessage) => void) | undefined, callback: ((res: IncomingMessage) => void) | undefined, protocol: 'http' | 'https'): ClientRequest;
/**
 * Server registry for tracking listening servers
 * Used by server bridge to route requests
 */
export type ServerRegistryCallback = (port: number, server: Server) => void;
export declare function _registerServer(port: number, server: Server): void;
export declare function _unregisterServer(port: number): void;
export declare function getServer(port: number): Server | undefined;
export declare function getAllServers(): Map<number, Server>;
export declare function setServerListenCallback(callback: ServerRegistryCallback | null): void;
export declare function setServerCloseCallback(callback: ((port: number) => void) | null): void;
/**
 * HTTP Agent - manages connection persistence and reuse
 * This is a stub implementation for browser environment
 */
export interface AgentOptions {
    keepAlive?: boolean;
    keepAliveMsecs?: number;
    maxSockets?: number;
    maxTotalSockets?: number;
    maxFreeSockets?: number;
    scheduling?: 'fifo' | 'lifo';
    timeout?: number;
}
export declare class Agent extends EventEmitter {
    maxSockets: number;
    maxFreeSockets: number;
    maxTotalSockets: number;
    sockets: Record<string, Socket[]>;
    freeSockets: Record<string, Socket[]>;
    requests: Record<string, IncomingMessage[]>;
    options: AgentOptions;
    constructor(opts?: AgentOptions);
    createConnection(_options: Record<string, unknown>, callback?: (err: Error | null, socket: Socket) => void): Socket;
    getName(options: {
        host?: string;
        port?: number;
        localAddress?: string;
    }): string;
    addRequest(_req: ClientRequest, _options: Record<string, unknown>): void;
    destroy(): void;
}
export declare const globalAgent: Agent;
declare const _default: {
    Server: typeof Server;
    IncomingMessage: typeof IncomingMessage;
    ServerResponse: typeof ServerResponse;
    ClientRequest: typeof ClientRequest;
    createServer: typeof createServer;
    request: typeof request;
    get: typeof get;
    STATUS_CODES: Record<number, string>;
    METHODS: string[];
    getServer: typeof getServer;
    getAllServers: typeof getAllServers;
    setServerListenCallback: typeof setServerListenCallback;
    setServerCloseCallback: typeof setServerCloseCallback;
    _createClientRequest: typeof _createClientRequest;
    Agent: typeof Agent;
    globalAgent: Agent;
};
export default _default;
//# sourceMappingURL=http.d.ts.map