import http from "node:http"; import stream from "node:stream"; import contentDisposition from "content-disposition"; import { Fritter } from "./Fritter.js"; import { FritterContext } from "./FritterContext.js"; /** Options for a FritterResponse's redirect method. */ export type FritterResponseRedirectOptions = { /** The status code to use for the redirect. */ statusCode?: 300 | 301 | 302 | 303 | 305 | 307 | 308; /** The URL to redirect to if there was no referer. */ fallbackRedirectUrl?: string; }; /** An object containing information about the response. */ export declare class FritterResponse { #private; /** The Fritter instance that created this request. */ fritter: Fritter; /** The Fritter context. */ fritterContext: FritterContext; /** The raw Node.js HTTP request. */ nodeRequest: http.IncomingMessage; /** The raw Node.js HTTP response. */ nodeResponse: http.ServerResponse; /** * Constructs a new Fritter response using the given Node.js HTTP response. * * @param fritter The Fritter instance that created this request. * @param fritterContext The Fritter context. * @param nodeRequest A Node.js HTTP request. * @param nodeResponse A Node.js HTTP response. */ constructor(fritter: Fritter, fritterContext: FritterContext, nodeRequest: http.IncomingMessage, nodeResponse: http.ServerResponse); /** Appends a value to the given header. */ appendHeaderValue(headerName: string, value: string): void; /** Appends a header name to the Vary header. */ appendVaryHeaderName(headerName: string): void; /** Gets the response body. */ getBody(): string | object | Buffer | stream | null; /** Gets the content length of the response body. */ getContentLength(): number | null; /** Gets the content type of the request. */ getContentType(): string | null; /** Gets the ETag header of the response. */ getEntityTag(): string | null; /** * If the request has no body, returns null. * * If the request has a body but is none of the types specified, returns false. * * Otherwise, returns the type of the request body. */ getFirstMatchingType(types: string[]): string | false; /** * Gets the first value of the given header. * * @param headerName The name of the header to get the value of. This is case-insensitive. * @returns The first value of the given header, or null if the header does not exist. */ getHeaderValue(headerName: string): string | null; /** * Gets all values of the given header. * * @param headerName The name of the header to get the values of. This is case-insensitive. * @returns An array of all values of the given header, or an empty array if the header does not exist. */ getHeaderValueArray(headerName: string): string[]; /** Gets the last modified date of the response. */ getLastModified(): Date | null; /** Gets the socket of the response. */ getSocket(): import("net").Socket | null; /** Gets the response status code. */ getStatusCode(): number; /** Gets whether the response body has been explicitly set to null. */ hasExplicitlyNullBody(): boolean; /** Gets whether the content type has been explicitly set. */ hasExplicitlySetContentType(): boolean; /** Checks if the response is still writable. */ isWritable(): boolean; /** Gets whether the response body has been explicitly set. */ hasExplicitlySetStatusCode(): boolean; /** Gets whether the response currently contains the given header. */ hasHeaderValues(headerName: string): boolean; /** Gets whether the response headers have been sent. */ hasSentHeaders(): boolean; /** Removes the given response header, if it exists. */ removeHeaderValue(name: string): void; /** Sets the response body. */ setBody(body: string | Buffer | object | stream.Stream | null): void; /** Sets the Content-Disposition header of the response. */ setContentDisposition(fileName: string | undefined, options: contentDisposition.Options | undefined): void; /** Sets the Content-Length header of the response. */ setContentLength(length: number | null): void; /** Sets the Content-Type header of the response. */ setContentType(type: string | null): void; /** Sets the ETag header of the response. */ setEntityTag(entityTag: string): void; /** * Sets a response header. * * Supplying an array of values will set multiple headers with the same name. */ setHeaderValue(name: string, value: string | string[]): void; /** Sets the Last-Modified header of the response. */ setLastModified(date: Date): void; /** * Sets the response to redirect to the given URL. * * You can also use the special URL "back" to redirect to the previous page, if the client sent a Referer header. */ setRedirect(url: string, options?: FritterResponseRedirectOptions): void; /** Sets the response status code. */ setStatusCode(statusCode: number): void; } //# sourceMappingURL=FritterResponse.d.ts.map