views:

32

answers:

1

Just for fun I was creating a JavaScript console for controlling my PC. It involves a small webserver that takes command strings and forwards those to the system using popen calls (to be more specific popen4 on a Ruby mongrel server). The stdout channels are redirected to the http response.

The problem is that the response only arrives once the entire contents of stdout has been sent. This is ok for small commands, but not for a command like find / which lists all the files in the system. In such situations it would be nice to have the results shown progressively in the webview (just like in the regular terminal).

I thought that using XMLHttpRequest synchronously might result in progressive downloading, but it doesn't seem so.

Is there any way to make it work?

+1  A: 

Quick question, are you flushing the response stream? If not the the request will wait until it has been. Just a thought as this is the case when creating progressive download of files etc

Richard
Not explicitly. Good suggestion, I'll try that first.
StackedCrooked