jquery - Subresource requests whose URLs contain embedded credentials are blocked (ip canera) -


i doing app web show streamings ip camera served on http , rtsp. workd til last month because google chrome not allow <iframe src="http://user:password@ip/"></iframe> more. reading cors/curl thing streaming on http n php got img doing this

<?php  $url="http://ip:port/blablabla";  $username="user";  $password="pass";  $fh = fopen("test.jpg", "w") or die($php_errormsg);  $ch = curl_init();  curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_userpwd, "$username:$password");  curl_setopt($ch, curlopt_httpauth, curlauth_any);  curl_setopt($ch, curlopt_protocols, curlproto_all);  curl_setopt($ch, curlopt_timeout, 5);  curl_setopt($ch, curlopt_file, $fh);  $success = curl_exec($ch);  $output = curl_exec($ch);  $info = curl_getinfo($ch);  curl_exec($ch);  curl_close($ch);  ?>

but need like, login can put <iframe src="http://ip/"></iframe> showing stream.

i tried xhr.request got error:

headers not present blabla allow origin xx

i installed plugin cors n google chrome , after shows other error: 500 saing not implemented dont know.

    var username = "user";      var password = "user";      var url = "http://ip/blablablabla";        function createcorsrequest(method, url) {    var xhr = new xmlhttprequest();    if ("withcredentials" in xhr) {      xhr.open(method, url, true);// xhr chrome/firefox/opera/safari.      xhr.setrequestheader("access-control-allow-origin",url);      xhr.setrequestheader("authorization", "basic ywrtaw46mtizndu=");      xhr.setrequestheader("access-control-allow-headers","access-control-allow-origin, access-control-allow-headers, origin, x-requested-with, content-type,corelation_id");      xhr.setrequestheader("access-control-expose-headers","www-authenticate, server-authorization");      } else if (typeof xdomainrequest != "undefined") {      xhr = new xdomainrequest();// xdomainrequest ie.      xhr.open(method, url, true , username, password);    } else {      xhr = null;  // cors not supported.    }    return xhr;  }  function gettitle(text) {// helper method parse title tag response.    return text.match('<title>(.*)?</title>')[1];  }  function makecorsrequest(url) {// make actual cors request.       var xhr = createcorsrequest('get', url);    if (!xhr) {      alert('cors not supported');      return;    }    xhr.onload = function() {// response handlers.      var text = xhr.responsetext;      var title = gettitle(text);      alert('response cors request ' + url + ': ' + title);    };    xhr.onerror = function() {      alert('woops, there error making request.');    };    xhr.send();  }  makecorsrequest(url);
found on internet , put headers trying solve that. atention , sorry writing part.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -