UNPKG

@curveball/core

Version:

Curveball is a framework writting in Typescript for Node.js

51 lines (50 loc) 1.51 kB
import { HeadersInterface, HeadersObject } from '@curveball/kernel'; import { NodeHttpResponse } from './http-utils.js'; /** * This is a wrapper around the Node Response object, and handles creates a * nicer API around Headers access. */ export default class NodeHeaders implements HeadersInterface { private inner; constructor(inner: NodeHttpResponse); /** * Sets a HTTP header name and value */ set(name: string, value: string): 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 not lowercased. Values may be either strings or arrays of * strings. */ getAll(): HeadersObject; /** * Appends a new header, without removing an old one with the same name. */ append(name: string, value: string | string[] | number): void; }