class
final
Represents the header configuration options for an HTTP request. Instances are immutable. Modifying methods return a cloned instance with the change. The original object is never changed.
class HttpHeaders { constructor(headers?: string | { [name: string]: string | string[]; }) has(name: string): boolean get(name: string): string | null keys(): string[] getAll(name: string): string[] | null append(name: string, value: string | string[]): HttpHeaders set(name: string, value: string | string[]): HttpHeaders delete(name: string, value?: string | string[]): HttpHeaders }
Constructs a new HTTP header object with the given values. | |||
|
headers | string | { [name: string]: string | string[]; } | Optional. Default is |
has() | |||
---|---|---|---|
Checks for existence of a given header. | |||
|
name | string | The header name to check for existence. |
boolean
: True if the header exists, false otherwise.
get() | |||
---|---|---|---|
Retrieves the first value of a given header. | |||
|
name | string | The header name. |
string | null
: The value string if the header exists, null otherwise
keys() |
---|
Retrieves the names of the headers. |
|
getAll() | |||
---|---|---|---|
Retrieves a list of values for a given header. | |||
|
name | string | The header name from which to retrieve values. |
string[] | null
: A string of values if the header exists, null otherwise.
append() | ||||||
---|---|---|---|---|---|---|
Appends a new value to the existing set of values for a header and returns them in a clone of the original instance. | ||||||
|
name | string | The header name for which to append the values. |
value | string | string[] | The value to append. |
HttpHeaders
: A clone of the HTTP headers object with the value appended to the given header.
set() | ||||||
---|---|---|---|---|---|---|
Sets or modifies a value for a given header in a clone of the original instance. If the header already exists, its value is replaced with the given value in the returned object. | ||||||
|
name | string | The header name. |
value | string | string[] | The value or values to set or overide for the given header. |
HttpHeaders
: A clone of the HTTP headers object with the newly set header value.
delete() | ||||||
---|---|---|---|---|---|---|
Deletes values for a given header in a clone of the original instance. | ||||||
|
name | string | The header name. |
value | string | string[] | The value or values to delete for the given header. Optional. Default is |
HttpHeaders
: A clone of the HTTP headers object with the given value deleted.
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/api/common/http/HttpHeaders