Pchp.Library.Output.ob_gzhandler C# (CSharp) Method

ob_gzhandler() public static method

Compresses data by gzip compression.
The function does not support subsequent calls to compress more chunks of data subsequentally.
public static ob_gzhandler ( Context ctx, PhpValue data, int mode ) : PhpValue
ctx Pchp.Core.Context Current runtime context.
data Pchp.Core.PhpValue Data to be compressed.
mode int Compression mode.
return Pchp.Core.PhpValue
        public static PhpValue ob_gzhandler(Context ctx, PhpValue data, int mode)
        {
            //// TODO: mode is not passed by Core properly. Therefore it is not possible to make subsequent calls to this handler.
            //// Otherwise headers of ZIP stream will be mishmashed.

            //// check input data
            //if (data == null) return false;

            //// check if we are running web application
            //var httpcontext = ctx.TryGetProperty<HttpContext>();
            //System.Collections.Specialized.NameValueCollection headers;
            //if (httpcontext == null ||
            //    httpcontext.Request == null ||
            //    (headers = httpcontext.Request.Headers) == null)
            //    return data ?? false;

            //// check if compression is supported by browser
            //string acceptEncoding = headers["Accept-Encoding"];

            //if (acceptEncoding != null)
            //{
            //    acceptEncoding = acceptEncoding.ToLowerInvariant();

            //    if (acceptEncoding.Contains("gzip"))
            //        return DoGzipHandler(ctx, data, httpcontext, ContentEncoding.gzip);

            //    if (acceptEncoding.Contains("*") || acceptEncoding.Contains("deflate"))
            //        return DoGzipHandler(ctx, data, httpcontext, ContentEncoding.deflate);
            //}

            //return data ?? false;
            throw new NotImplementedException(); // move to pchplib.web.dll
        }