Problems with xmlhttprequest status 302

前端 未结 1 1796
一向
一向 2020-12-19 15:49

I am trying to get real path in link megaupload but always but this dont work.

function getRealURL(){

    var st = new String(\"\"); 
    var req = new XMLH         


        
1条回答
  •  隐瞒了意图╮
    2020-12-19 16:18

    XMLHttpRequest follows the redirect automatically by default so you don't see the 302 response. You need to set nsIHttpChannel.redirectionLimit property to zero to prevent it:

    req.open("GET","http://www.megaupload.com/?d=6CKP1MVJ",true);
    req.channel.QueryInterface(Components.interfaces.nsIHttpChannel).redirectionLimit = 0;
    req.send(null);
    

    Not that the link you use here redirects anywhere but this is the general approach. Btw, instead of looking at the response text for redirects you should look at req.getResponseHeader("Location").

    0 讨论(0)
提交回复
热议问题