mock-xmlhttprequest
Version:
XMLHttpRequest mock for testing
47 lines (45 loc) • 1.16 kB
text/typescript
/**
* mock-xmlhttprequest v8.4.1
* (c) 2025 Bertrand Guay-Paquet
* @license MIT
*/
/**
* HTTP header container
*/
export default class HeadersContainer {
private _headers;
/**
* @param headers Initial headers
*/
constructor(headers?: Record<string, string> | null);
constructor(src: HeadersContainer);
/**
* Reset the container to its empty state.
*
* @returns this
*/
reset(): this;
/**
* @param name Header name (case insensitive)
* @returns Header value or null
*/
getHeader(name: string): string | null;
/**
* Get all headers as a string. Each header is on its own line. All header names are lower-case.
*
* @returns Concatenated headers
*/
getAll(): string;
/**
* @returns All headers as an object. The header names are in lower-case.
*/
getHash(): Record<string, string>;
/**
* Add a header value, combining it with any previous value for the same header name.
*
* @param name Header name
* @param value Header value
* @returns this
*/
addHeader(name: string, value: string): this;
}