3 * Experimental version that return chunked http response.
5 * Pulling the values is no longer needed as the one request will output
6 * the updates every 10 seconds.
8 require_once('config.php');
10 header("Content-Type: text/json");
11 header("Transfer-Encoding: chunked");
15 // Send chunk to browser
16 function send_chunk($chunk)
18 // The chunk must fill the output buffer or php won't send it
19 $chunk = str_pad($chunk, 4096);
21 printf("%x\r\n%s\r\n", strlen($chunk), $chunk);
26 $info=rrd_lastupdate(RRDFILE);
29 'last_update' => 'unknown',
31 'error' => rrd_error(),
35 'last_update' => $info['last_update'],
36 'watts' => $info['data'][0]
38 send_chunk(json_encode($result));