Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Dev Tools not showing all request headers [duplicate]

I'd like to know why my Chrome Dev Tools is not showing the headers I put on a request. I would like to send a request to Twitter API and it requires an Authorization header.

I am executing the following code:

 getTweets(hashtag : string){
        var headers = new Headers();
        headers.append('Test-Test', '123456789');
        headers.append('Authorization', 'Bearer AAAAAAAAAAAAAAAAAAAAAONruQAQda4njz64ske7axXN9sw4U0oU%3Dr1niTwVKwXomZczDKgN0wWHWEMPrPcnXXMgVQhiTIzays7J');


      return this.jsonp.get('https://api.twitter.com/1.1/search/tweets.json?q=canada&callback=JSONP_CALLBACK', {headers: headers});  
    }

However it is not returning the data as expected.

When I go to the Chrome Dev Tools, I do not see the headers I added listed in the request.

Chrome Dev Tools Request

Why is this? Am I not adding the headers properly? Does Chrome Dev Tools only display the basic headers? What's going on?

like image 713
CodyBugstein Avatar asked Apr 10 '16 06:04

CodyBugstein


1 Answers

There is no way to control headers sent by a browser while using JSONP. JSONP is a smart trick (or a hack, depending on how you see it...) that consist of inserting a <script> tag pointing to a server endpoint. Ultimately it is a browser who will decide which headers to sent while requesting scripts via <script> tag and you can't influence it.

From : https://stackoverflow.com/a/19604865/3279156

like image 150
sreeramu Avatar answered Oct 07 '22 23:10

sreeramu