It seems like I can't add an Authorization Header to an XMLHttpRequest.
Here the javascript code :
var xhr = new XMLHttpRequest();
xhr.open('GET', "http://localhost:8080", true);
xhr.setRequestHeader('Authorization', 'Bearer hefiafizepzgenozngopzngpzegn');
xhr.send();
Here the log on my local server :
Request : /
Headers : {"host":"localhost:8080","accept":"*/","accept-language":"en-us","connection":"keep-alive","accept-encoding":"gzip, deflate","user-agent":"Test/1 CFNetwork/758.1.2 Darwin/14.5.0"}
Did I miss something ?
Thanks for your help
PS : Note that if I rename the header "X-Authorization" it works.
The authorization header among other headers are restricted. Mode details are available here: https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/#//apple_ref/occ/instm/NSMutableURLRequest/addValue:forHTTPHeaderField: