Hi,
This is another question about custom python controllers and endpoints.
I have programmed a custom endpoint available at: http://localhost:8080/en-US/custom/my_app/my_script/test
I make an ajax request from a browser inserting an Authorization header.
I am trying to read the value of this header in my python controller, but it doesn't appear.
I have tried using cherrypy headers, but although I get plenty of HTTP headers, I can't see the one I want: Authorization .
Any hints on why I get some headers but not that one?
I have my endpoint script in appserver/controllers:
#my_script.py
import splunk.appserver.mrsparkle.controllers as controllers
from splunk.appserver.mrsparkle.lib.decorators import expose_page
import cherrypy
class Controller(controllers.BaseController):
@expose_page(must_login=False, methods=['GET'])
def test(self, **kwargs) :
return cherrypy.request.headers.output()
This is my ajax request:
$.ajax({
type: "GET",
crossDomain:true,
url: "http://localhost:8080/en-US/custom/my_app/my_script/test",
headers: {
"Authorization" : "whatever"
},
success: function (response){
console.log(response);
}
});
This is what I get as a response:
[('Te', 'chunked'),
('Accept-Encoding', 'gzip'),
('Host', 'localhost:8080'),
('Accept', '*/*'),
('X-Splunkd', 'Z/sOmesTrINg/A=='),
('Remote-Addr', '127.0.0.1'),
('Referer', 'https://server-of-origin/page.html'),
('Accept-Language', 'en-US,en;q=0.8'),
('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36'),
('Origin', 'https://server-of-origin')]
What I am expecting is to see another tuple like: ('Authorization','whatever')
... View more