@curveball/kernel
Version:
Curveball is a framework writting in Typescript for Node.js
98 lines (97 loc) • 2.78 kB
TypeScript
/**
* This interface represents a set of HTTP headers.
*/
export interface HeadersInterface {
/**
* Sets a HTTP header name and value
*/
set(name: string, value: string | string[] | number): void;
/**
* Gets a HTTP header's value.
*
* This function will return null if the header did not exist. If it did
* exist, it will return a string.
*
* If there were multiple headers with the same value, it will join the
* headers with a comma.
*/
get(name: string): string | null;
/**
* Gets all values of a HTTP header
*
* This function will return an array with 0 or more values of a header.
*
*/
getMany(name: string): string[];
/**
* Returns true or false depending on if a HTTP header exists.
*/
has(name: string): boolean;
/**
* Removes a HTTP header
*/
delete(name: string): void;
/**
* Returns all HTTP headers.
*
* Headernames are lowercased. Values may be either strings or arrays of
* strings or numbers.
*/
getAll(): HeadersObject;
/**
* Appends a new header, without removing an old one with the same name.
*/
append(name: string, value: string | string[] | number): void;
}
/**
* This type is a simple key-value object that can be used to instantiate a
* Headers class.
*/
export type HeadersObject = {
[headerName: string]: string | string[] | number;
};
export declare class Headers implements HeadersInterface {
private store;
constructor(headersObj?: HeadersObject);
/**
* Sets a HTTP header name and value.
*/
set(name: string, value: string | string[] | number): void;
/**
* Gets a HTTP header's value.
*
* This function will return null if the header did not exist. If it did
* exist, it will return a string.
*
* If there were multiple headers with the same value, it will join the
* headers with a comma.
*/
get(name: string): string | null;
/**
* Gets all values of a HTTP header
*
* This function will return an array with 0 or more values of a header.
*
*/
getMany(name: string): string[];
/**
* Returns true or false depending on if a HTTP header exists.
*/
has(name: string): boolean;
/**
* Returns all HTTP headers.
*
* Headernames are lowercased. Values may be either strings or arrays of
* strings or numbers.
*/
getAll(): HeadersObject;
/**
* Appends a new header, without removing an old one with the same name.
*/
append(name: string, value: string | string[] | number): void;
/**
* Removes a HTTP header
*/
delete(name: string): void;
}
export default Headers;