Difference between revisions of "User:Woozle/two-way http"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(dumping all the relevant stuff I can find, to clear it off)
 
(moved JS links to appropriate page)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
This is mainly a quick tabdump of pages I had open while trying to figure out how to let a server push updates to a web browser, as described [https://plus.google.com/u/0/102282887764745350285/posts/YLkt2tQESB9 here]:
 
This is mainly a quick tabdump of pages I had open while trying to figure out how to let a server push updates to a web browser, as described [https://plus.google.com/u/0/102282887764745350285/posts/YLkt2tQESB9 here]:
* https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
+
* [[JavaScript]] now has all the JavaScript liniks
** https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - reference
 
* {{l/wp|JavaScript}}: has some code snippets
 
** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
 
** http://htmldog.com/guides/javascript/advanced/creatingelements/
 
** http://htmldog.com/guides/javascript/beginner/makingstuffhappen/
 
 
* [[WebSockets]]:
 
* [[WebSockets]]:
 
** [https://github.com/kanaka/websockify/wiki websockify]
 
** [https://github.com/kanaka/websockify/wiki websockify]
Line 17: Line 12:
 
** http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_p
 
** http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_p
 
* https://www.meteor.com/tutorials/blaze/creating-an-app -- need to be able to serve this over https, somehow
 
* https://www.meteor.com/tutorials/blaze/creating-an-app -- need to be able to serve this over https, somehow
 +
* http://php.net/manual/en/function.header.php - sending http headers
 
==Code==
 
==Code==
 
This didn't work (in .htaccess):
 
This didn't work (in .htaccess):

Latest revision as of 21:04, 13 December 2015

This is mainly a quick tabdump of pages I had open while trying to figure out how to let a server push updates to a web browser, as described here:

Code

This didn't work (in .htaccess): ProxyPass /meteor http://localhost:3000 ProxyPassReverse /meteor http://localhost:3000

This does work, for the front end: <php>

$out = '

Hello Cruel World

';

$out .= <<<__END__

<script> console.log("GOT TO HERE");

 var ctMain = document.getElementById('main');
 ctMain.innerHTML = "Fetching page...
";

// req.onload = function (event) {

 function evPageLoaded(event) {
   ctMain.innerHTML = req.responseText + 'L';
 };
 function evPageUpdate(event) {
   ctMain.innerHTML = req.responseText + 'U';
 };
 function evPageFailed(event) {
   ctMain.innerHTML = req.responseText + 'Houston, we have a problem.';
 }
 function evPageKilled(event) {
   ctMain.innerHTML = req.responseText + 'Cancelled';
 }
 
 var req = new XMLHttpRequest();
 
 req.addEventListener("progress", evPageUpdate);
 req.addEventListener("load", evPageLoaded);

// req.addEventListener("error", transferFailed); // req.addEventListener("abort", transferCanceled);

// req.open('get', 'https://vbz.net/phpinfo.php', true); // req.open('get', 'https://vbz.net/ajax', true);

 req.open('get', 'http://vbz.net:3000', true);
 req.send();

</script> __END__; return $out; </php>

This gets dumped all at once when sent via Apache, but displays incrementally via CLI: <php> if (ob_get_level() == 0) ob_start();

//header('Content-Type: Multipart/mixed; boundary="___BOUNDARY___";'); header('Content-Type: multipart/x-mixed-replace; boundary="___BOUNDARY___";');

echo "\n"; echo "___BOUNDARY___\n"; echo "Content-Type: text/html; charset=utf-8\n"; echo "\n";

for ($count = 1; $count <= 10; $count++) {

   echo "\n";
   echo "___BOUNDARY___\n";
   echo "Content-Type: text/html; charset=utf-8\n";
   echo "\n";
   echo "$count
\n"; //echo str_pad(,8192)."\n"; ob_flush(); flush(); usleep(500000);

} echo "___BOUNDARY___\n"; ob_end_flush(); </php>