Chrome API responseHeaders -


based on documentation: https://developer.chrome.com/extensions/webrequest.html#event-onheadersreceived

i tried display response via console like:

console.log(info.responseheaders);

but returning undefined.

but works though:

console.log("type: " + info.type);

please help, need responseheaders data.

you have request response headers this:

chrome.webrequest.onheadersreceived.addlistener(function(details){   console.log(details.responseheaders); }, {urls: ["http://*/*"]},["responseheaders"]); 

an example of use. 1 instance of how use webrequest api in extension. (only showing partial incomplete code)

i need indirectly access server data , making use of 302 redirect page. send head request desired url this:

$.ajax({   url: url,   type: "head"   success: function(data,status,jqxhr){     //if not head request, `data` contain response     //but in case need headers `data` empty     compareposts(jqxhr.getresponseheader('redirurl')); //where handle data   }      }); 

and silently kill redirect while scraping location header own uses using webrequest api:

chrome.webrequest.onheadersreceived.addlistener(function(details){   if(details.method == "head"){     var redirurl;     details.responseheaders.foreach(function(v,i,a){       if(v.name == "location"){        redirurl = v.value;        details.responseheaders.splice(i,1);       }     });     details.responseheaders.push({name:"redirurl",value:redirurl});     return {responseheaders:details.responseheaders}; //i kill redirect   } }, {urls: ["http://*/*"]},["responseheaders","blocking"]); 

i handle data inside onheadersreceived listener, way shows response data be.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -