function headers_render($header, $len)
{
-
$s = "";
- $s .= "HTTP/1.1 200 OK\r\n";
+ if (isset($header['Location'])) {
+ return sprintf("HTTP/1.1 302 OK\r\nLocation: %s\r\n\r\n", $header['Location']);
+ }
+ else {
+ $s .= "HTTP/1.1 200 OK\r\n";
+ }
if (!isset($header['Date']))
$s .= sprintf("Date: %s\r\n", date(DATE_RFC822));
if (!isset($header['Connection']))
}
$write = NULL;
$except = NULL;
- $num_changed_sockets = stream_select($read, $write, $except, 0, 250000);
+ $num_changed_sockets = stream_select($read, $write, $except, 5, 0);
if ($num_changed_sockets == 0) {
printf(" no data in 5 secs ");
}
}
+ /*
+ $response: raw stream data not sent
+ $content: html consistent data (<script bla bla>)
+ $user->stream_keepalive($w_ping) ping srv->cli OR srv->cli + cli->srv if $w_ping == TRUE
+ */
+
/* manage open streaming */
foreach ($this->socks as $k => $sock) {
if (isset($this->s2u[intval($sock)])) {
$content = "";
$user->stream_main($content, $get, $post, $cookie);
printf("[%s] [%d] [%d]\n", $user->name, $user->lacc, $this->curtime);
- if ($content == "" && $user->ping_req == FALSE
+ if (/* $content == "" && */ $user->ping_req == FALSE
&& (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 2))) {
- $content = $user->stream_ping();
+ // $content = $user->stream_keepalive(TRUE);
+ $content += $user->stream_keepalive(TRUE);
$user->ping_req = TRUE;
}
if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
- $content = $user->stream_keepalive();
+ $content = $user->stream_keepalive(FALSE);
}
if ($content != "") {
$response = chunked_content($content);
}
if ($response != "") {
- echo "SPIA: [".substr($response, 0, 60)."...]\n";
+ // echo "SPIA: [".substr($response, 0, 60)."...]\n";
+ echo "SPIA: [".$response."...]\n";
$response_l = mb_strlen($response, "ASCII");
$wret = @fwrite($sock, $response);
if ($wret < $response_l) {