Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India asked on

Why does Safari does not allow trailing space in header value

HI,
I noticed that especially in safari if i made an ajax call say like :

headers : {"dsds" : "asdasdas  "}
As this has a trailing space at the end... This will result in an exception.
What could be the reason for this.. As this is not happening for other browsers ??

Thanks
Web BrowsersjQuery

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
Julian Hansen

We need a context for this, a link and / or screen shot, a full description of the error and a look at the underlying code.
Rohit Bajaj

ASKER
Hi,
I have attached the screenshot of safari console tab. Here if i give a trailing space at the end of a request header it throws an exception otherwise it just runs fine...
Screen-Shot-2016-10-06-at-11.11.17-A.png
Julian Hansen

Still not enough - we need to see the code.

Sidebar - is the space on the end necessary - why not simply trim it before sending.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Rohit Bajaj

ASKER
Thats the whole code in the screenshot just create an xhr request and add an header with a trailing space at the end... It throws an error this does not happen in chrome.. or firefox...
Yes thats what i am planning to do just trim the space before sending....
Just wanted to know if there is any possible reason why safari has done that  and not chrome...
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.