Class Overview
class Headers { staticfromResponseHeaderString(headersString: string) : Headers constructor(headers?: Headers|{[key: string]: any}) append(name: string, value: string) : void delete(name: string) : void forEach(fn: (values: string[], name: string, headers: Map<string, string[]>) => void) : void get(header: string) : string has(header: string) : boolean keys() : string[] set(header: string, value: string|string[]) : void values() : string[][] toJSON() : {[key: string]: any} getAll(header: string) : string[] entries() }
Class Description
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 '@angular/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})
Static Members
fromResponseHeaderString(headersString: string) : Headers
Returns a new Headers instance from the given DOMString of Response Headers
Class Details
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
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() : {[key: string]: any}
Returns string of all headers.
getAll(header: string) : string[]
Returns list of header values for a given name.
entries()
This method is not implemented.
exported from @angular/http/index, defined in @angular/http/src/headers.ts
Please login to continue.