UNPKG

@microsoft/kiota-abstractions

Version:

Core abstractions for kiota generated libraries in TypeScript and JavaScript

126 lines 5.28 kB
/** * A collection class for HTTP headers. The keys are case-insensitive. * @example * ```typescript * const headers = new Headers(); * headers.add("header1", "value1"); * ``` */ export declare class Headers extends Map<string, Set<string>> { private headers; private readonly singleValueHeaders; /** * Creates a new Headers object. * @param entries An iterable object that contains key-value pairs. Each key-value pair must be an array with two elements: the key of the header, and the value of the header. * @example * ```typescript * const entries: [string, Set<string>][] = [ * ['header1', new Set(['value1'])], * ['header2', new Set(['value2', 'value3'])] * ]; * const headers = new Headers(entries); * ``` */ constructor(entries?: readonly (readonly [string, Set<string>])[] | null); /** * Sets a header with the specified name and value. If a header with the same name already exists, its value is appended with the specified value. * @param headerName the name of the header to set * @param headerValue the value of the header to set * @returns Headers object */ set(headerName: string, headerValue: Set<string>): this; /** * Gets the values for the header with the specified name. * @param headerName The name of the header to get the values for. * @returns The values for the header with the specified name. * @throws Error if headerName is null or empty */ get(headerName: string): Set<string> | undefined; /** * Checks if a header exists. * @param key The name of the header to check for. * @returns whether or not a header with the given name/key exists. */ has(key: string): boolean; /** * Delete the header with the specified name. * @param headerName The name of the header to delete. * @returns Whether or not the header existed and was deleted. * @throws Error if headerName is null or empty */ delete(headerName: string): boolean; /** * clear the headers collection */ clear(): void; /** * execute a provided function once per each header * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each header in the dictionary. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: Set<string>, key: string, map: Map<string, Set<string>>) => void, thisArg?: any): void; /** * Adds values to the header with the specified name. * @param headerName The name of the header to add values to. * @param headerValues The values to add to the header. * @returns Whether or not the values were added to the header. */ add(headerName: string, ...headerValues: string[]): boolean; /** * Adds values to the header with the specified name if it's not already present * @param headerName The name of the header to add values to. * @param headerValue The values to add to the header. * @returns If the headerValue have been added to the Dictionary. */ tryAdd(headerName: string, headerValue: string): boolean; /** * Removes the specified value from the header with the specified name. * @param headerName The name of the header to remove the value from. * @param headerValue The value to remove from the header. * @returns Whether or not the header existed and was removed. * @throws Error if headerName is null or empty * @throws Error if headerValue is null */ remove(headerName: string, headerValue: string): boolean; /** * Adds all the headers values from the specified headers collection. * @param headers The headers to update the current headers with. * @throws Error if headers is null */ addAll(headers: Headers): void; /** * Adds all headers from the request configuration value to the current headers collection. * Replaces any existing headers with the same key. * @param headers The headers to update the current headers with. * @throws Error if headers is null */ addAllRaw(headers: Record<string, string | string[]>): void; /** * Gets the values for the header with the specified name. * @param key The name of the header to get the values for. * @returns The values for the header with the specified name. * @throws Error if key is null or empty */ tryGetValue(key: string): string[] | null; /** * Override toString method for the headers collection * @returns a string representation of the headers collection */ toString(): string; /** * check if the headers collection is empty * @returns a boolean indicating if the headers collection is empty */ isEmpty(): boolean; /** * get keys of the headers collection * @returns an iterator of keys */ keys(): MapIterator<string>; /** * get entries * @returns an iterator of entries */ entries(): MapIterator<[string, Set<string>]>; } //# sourceMappingURL=headers.d.ts.map