@mojojs/core
Version:
Real-time web framework
71 lines (70 loc) • 1.76 kB
TypeScript
type HeaderBuffer = Record<string, {
normalCase: string;
values: string[];
}>;
/**
* HTTP header class.
*/
export declare class Headers {
_headers?: HeaderBuffer;
_init: string[];
constructor(init?: string[]);
/**
* Append header value.
*/
append(name: string, value: string): this;
/**
* Clone headers.
*/
clone(): Headers;
/**
* Remove hop-by-hop headers that should not be retransmitted.
*/
dehop(): this;
/**
* Get header value.
*/
get(name: string): string | null;
/**
* Get all headers values individually.
*/
getAll(name: string): string[];
/**
* Get web links from `Link` header according to RFC5988.
* @link http://tools.ietf.org/html/rfc5988
* @example
* // Extract information about next page
* const {link, title} = headers.getLinks().next;
*/
getLinks(): Record<string, Record<string, string>>;
/**
* Remove header.
*/
remove(name: string): this;
/**
* Set header value.
*/
set(name: string, value: string): this;
/**
* Set web links to `Link` header according to RFC5988.
* @link http://tools.ietf.org/html/rfc5988
* @example
* // Link to next and previous page
* headers.setLinks({next: 'http://example.com/foo', prev: 'http://example.com/bar'});
*/
setLinks(links: Record<string, string>): this;
/**
* Convert headers into a plain array of name/value pairs.
*/
toArray(): string[];
/**
* Convert headers into a plain object.
*/
toObject(): Record<string, string>;
/**
* Convert headers to string.
*/
toString(): string;
_getHeaders(): HeaderBuffer;
}
export {};