X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fspush%2Fbrisk-spush.phh;h=5b736fbc031cdb9eb9d61a39e24cc84be8ea69ce;hb=d79148fdd170bec2b88a3289ad8d2ae229163cc7;hp=7f9531619beed69acdd237673d63cfe7f7c083b7;hpb=cb0a7d2568702826016699ac2f4d2c2cfdd66dcc;p=brisk.git diff --git a/web/spush/brisk-spush.phh b/web/spush/brisk-spush.phh index 7f95316..5b736fb 100644 --- a/web/spush/brisk-spush.phh +++ b/web/spush/brisk-spush.phh @@ -27,7 +27,7 @@ $HTTP_HOST="dodo.birds.lan"; define('USOCK_PATH', "/tmp/brisk.sock"); define('PENDINGPAGE_WAITDATA', 0); -define('PENDINGPAGE_FLUSHING', 1); +define('PENDINGPAGE_FLUSH', 1); class PendingPage { @@ -38,18 +38,39 @@ class PendingPage { var $msg; // place where store failed fwrite data var $msg_sz; // size of content - - - function PendingPage($socket) + var $method; // method used to request the page + var $header; // array of header fields + var $get; // array of get args + var $post; // array of post args + var $cookie; // array of cookie args + var $path; // requested path + var $addr; // source address + var $contsz; // expected content size + var $rest; // number of missing bytest + + function PendingPage($socket, $curtime, $kalive) { $this->socket = $socket; + $this->kalive = $curtime + $kalive; } - static function pendingpage_waiting($socket, $method, $header, $get, $post, $cookie, $path, $addr) + static function pendingpage_waiting($socket, $curtime, $kalive, $method, $header, + $get, $post, $cookie, $path, $addr, $rest) { - $thiz = new PendingPage($socket); + $thiz = new PendingPage($socket, $curtime, $kalive); + $thiz->status = PENDINGPAGE_WAITDATA; + + $thiz->method = $method; + $thiz->header = $header; + $thiz->get = $get; + $thiz->post = $post; + $thiz->cookie = $cookie; + $thiz->path = $path; + $thiz->addr = $addr; + $thiz->contsz = $header['Content-Length']; + $thiz->rest = $rest; - // TODO + return ($thiz); } function try_wait($curtime) @@ -60,14 +81,14 @@ class PendingPage { static function pendingpage_flushing($socket, $curtime, $kalive, $enc, $header_out, $body) { - $thiz = new PendingPage($socket); + $thiz = new PendingPage($socket, $curtime, $kalive); - $thiz->to_flushing($enc, $curtime, $kalive, $header_out, $body); + $thiz->to_flushing($enc, $header_out, $body); return ($thiz); } - function to_flushing($enc, $curtime, $kalive, $header_out, $body) + function to_flushing($enc, &$header_out, $body) { printf("TRY FLUSH CREATE\n"); $body_out = ZLibStream::compress($enc, $body); @@ -77,8 +98,7 @@ class PendingPage { $hea = headers_render($header_out, $body_out_sz); $hea_sz = mb_strlen($hea, "ASCII"); - $this->status = PENDINGPAGE_FLUSHING; - $this->kalive = $curtime + $kalive; + $this->status = PENDINGPAGE_FLUSH; $this->msg = $hea.$body_out; $this->msg_sz = $hea_sz + $body_out_sz; } @@ -86,7 +106,7 @@ class PendingPage { /* return TRUE if is removable from it's list */ function try_flush($curtime) { - if ($this->status != PENDINGPAGE_FLUSHING) + if ($this->status != PENDINGPAGE_FLUSH) return (FALSE); printf("TRY FLUSH IN\n");