Angular 2 rc.6
implemented in typescript 2
I've developed a custom wrapper for the Http
service to add specific headers. In the snippet below, options
represents the RequestOptions
object passed to Http.get()
:
//if content type is not specified, default to application/json
if(!options.headers.has("Content-Type")){
options.headers.append("Content-Type", "application/json")
}
//include X-CUSTOM-HEADER header
if(!options.headers.has("X-CUSTOM-HEADER")){
options.headers.append("X-CUSTOM-HEADER", "value");
}
Upon making a request from my application, the network log in the browser (Firefox 48
) displays:
Content-Type: "application/json"
x-custom-header: "value"
Can anyone explain why the second header's name is being converted to lowercase?
PS: Thank you for the responses. Is it just me or does this inconsistency bother anyone else? Why would Angular lowercase some headers while leaving others as they are???