Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

Keep case on header names in angular

I have an angular project at work that talks to an API I have no control over. It seems like that API is case sensitive on the headers, which I know isn't right but I can't do anything about it now. The latest versions of angular seem to be changing the case of all headers to lower case, is there any way of preventing that from happening ? If not I'll have to figure out how to downgrade all that I guess.

    headers = new HttpHeaders();
    headers = headers.set('MyGreatHeader', "value");

That's now sending: mygreatheader: value in the http request.

Thank you

question from:https://stackoverflow.com/questions/65860676/keep-case-on-header-names-in-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The issue is actually not angular but the version of HTTP, turns out HTTP/2 forces all header to be lower case. I've disabled HTTP/2 for now to fix it, while I try to get the API code addressed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...