Headers

export class Headers

exported from angular2/http defined in angular2/src/http/headers.ts (line 16)

Polyfill for Headers, as specified in the Fetch Spec.

The only known difference between this Headers implementation and the spec is the lack of an entries method.

Example (live demo)

import {Headers} from 'angular2/http'; var firstHeaders = new Headers(); firstHeaders.append('Content-Type', 'image/jpeg'); console.log(firstHeaders.get('Content-Type')) //'image/jpeg' // Create headers from Plain Old JavaScript Object var secondHeaders = new Headers({ 'X-My-Custom-Header': 'Angular' }); console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular' var thirdHeaders = new Headers(secondHeaders); console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'

Constructor

constructor(headers?: Headers | {[key: string]: any})

Not Yet Documented

Members

append(name: string, value: string) : void

Appends a header to existing list of header values for a given header name.

delete(name: string) : void

Deletes all header values for the given name.

forEach(fn: (values: string[], name: string, headers: Map<string, string[]>) => void) : void

Not Yet Documented

get(header: string) : string

Returns first header that matches given name.

has(header: string) : boolean

Check for existence of header by given name.

keys() : string[]

Provides names of set headers

set(header: string, value: string | string[]) : void

Sets or overrides header value for given name.

values() : string[][]

Returns values of all headers.

toJSON() : string

Returns string of all headers.

getAll(header: string) : string[]

Returns list of header values for a given name.

entries()

This method is not implemented.