From: Matteo Nastasi (mop) Date: Fri, 16 Aug 2013 08:50:24 +0000 (+0200) Subject: moved chunked_content into user class and set chunked as optional X-Git-Tag: v4.9.0~2^2 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=9a17da4020740578e3a744630fd6be96c8237cab;p=brisk.git moved chunked_content into user class and set chunked as optional --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index d90c2ea..593b6e2 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2368,7 +2368,7 @@ class Room $content = ""; $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie); - $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content); + $response = headers_render($header_out, -1).$user->chunked_content($content); $response_l = mb_strlen($response, "ASCII"); $wret = @fwrite($new_socket, $response, $response_l); diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index c0e2db1..502670d 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -268,25 +268,6 @@ register_shutdown_function('shutta'); * MAIN */ -function chunked_content($zls, $content) -{ - if ($zls) { - $cont_comp = $zls->compress_chunk($content); - } - else { - $cont_comp = $content; - } - $cont_comp_l = mb_strlen($cont_comp, "ASCII"); - // printf("CHUNK: [%s]\n", $content); - - return (sprintf("%X\r\n", $cont_comp_l).$cont_comp."\r\n"); -} - -function chunked_fini() -{ - return sprintf("0\r\n"); -} - function get_encoding($header) { $enc = "plain"; @@ -860,7 +841,7 @@ class Sac_a_push { $content = $user->stream_keepalive(FALSE); } if ($content != "") { - $response = chunked_content($user->rd_zls_get(), $content); + $response = $user->chunked_content($content); } } diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index 2d9714e..a77fad7 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -69,6 +69,10 @@ class Transport_template { function chunk($step, $cont) { } + + function is_chunked() + { + } } class Transport_xhr { @@ -98,6 +102,11 @@ class Transport_xhr { { return ("@BEGIN@".$cont."@END@"); } + + function is_chunked() + { + return TRUE; + } } class Transport_iframe { @@ -166,6 +175,11 @@ push(null);\n// -->\n", $step); push(\"%s\");\n// -->\n", $step, escpush($cont) ); } } + + function is_chunked() + { + return TRUE; + } } class Transport_htmlfile extends Transport_iframe { diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 11b808f..f52bc3e 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -108,6 +108,7 @@ class User { var $rd_cache; // place where store failed fwrite data var $rd_zls; // zlibstream object handle if compressed stream, else FALSE var $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...) + var $rd_is_chunked; // is the transport chunked or not ? var $comm; // commands array // var $asta_card; // @@ -168,6 +169,7 @@ class User { $thiz->rd_cache = ""; $thiz->rd_zls = FALSE; $thiz->rd_transp = NULL; + $thiz->rd_is_chunked = FALSE; $thiz->asta_card = -2; $thiz->asta_pnt = -1; @@ -330,6 +332,7 @@ class User { $this->rd_kalive = $curtime + RD_KEEPALIVE_TOUT; $this->rd_zls = ZLibStream::create($enc); $this->rd_transp = Transport::create($transp); + $this->rd_is_chunked = $this->rd_transp->is_chunked(); } function rd_socket_get() { @@ -779,6 +782,37 @@ function is_supp_custom() return (FALSE); } +function is_chunked() +{ + return $this->rd_is_chunked; +} + + +function chunked_content($content) +{ + if ($this->rd_zls) { + $cont_comp = $this->rd_zls->compress_chunk($content); + } + else { + $cont_comp = $content; + } + $cont_comp_l = mb_strlen($cont_comp, "ASCII"); + // printf("CHUNK: [%s]\n", $content); + + if ($this->is_chunked()) { + return (sprintf("%X\r\n", $cont_comp_l).$cont_comp."\r\n"); + } + else { + return $content; + } +} + +function chunked_fini() +{ + return sprintf("0\r\n"); +} + + } // end class User diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 10edf1b..6e3a52f 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1234,7 +1234,7 @@ class Bin5 { $content = ""; $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie); - $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content); + $response = headers_render($header_out, -1).$user->chunked_content($content); $response_l = mb_strlen($response, "ASCII"); $wret = @fwrite($new_socket, $response, $response_l);