PHP's ob_gzhandler equivalent in Perl ?

Discussion in 'Perl Misc' started by howa, Nov 15, 2008.

  1. howa

    howa Guest

    In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    data to web browsers that support compressed web pages

    Are there any similar stuff in CGI or related Perl modules?

    Thanks.
    howa, Nov 15, 2008
    #1
    1. Advertising

  2. howa <> wrote:
    >In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    >data to web browsers that support compressed web pages


    I've not heard of gz-encoding. Are you talking about GNU-zip, aka gzip,
    aka tarballs?

    >Are there any similar stuff in CGI or related Perl modules?


    There are numerous modules at
    http://search.cpan.org/search?query=gzip&mode=all

    jue
    Jürgen Exner, Nov 15, 2008
    #2
    1. Advertising

  3. On 2008-11-15 16:49, Jürgen Exner <> wrote:
    > howa <> wrote:
    >>In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    >>data to web browsers that support compressed web pages

    >
    > I've not heard of gz-encoding. Are you talking about GNU-zip, aka gzip,


    Presumably, since gzip is one of the specified compression methods
    specified in the HTTP protocol (the other two are "deflate" (uses the
    same method as gzip, but a different header) and "compress").

    > aka tarballs?


    No. Tarballs are tar archives, i.e., collections of files serialized
    into a single file. They are not necessarily compressed, and even if
    they are compressed, they may be compressed by any compression method,
    not just gzip (bzip2 and compress are also common).


    >>Are there any similar stuff in CGI or related Perl modules?

    >
    > There are numerous modules at
    > http://search.cpan.org/search?query=gzip&mode=all


    Many web servers also have a compression module, so you may not have to
    do anything in the CGI script at all.

    hp
    Peter J. Holzer, Nov 15, 2008
    #3
  4. howa

    Thrill5 Guest

    "Peter J. Holzer" <> wrote in message
    news:...
    > On 2008-11-15 16:49, Jürgen Exner <> wrote:
    >> howa <> wrote:
    >>>In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    >>>data to web browsers that support compressed web pages

    >>
    >> I've not heard of gz-encoding. Are you talking about GNU-zip, aka gzip,

    >
    > Presumably, since gzip is one of the specified compression methods
    > specified in the HTTP protocol (the other two are "deflate" (uses the
    > same method as gzip, but a different header) and "compress").
    >
    >> aka tarballs?

    >
    > No. Tarballs are tar archives, i.e., collections of files serialized
    > into a single file. They are not necessarily compressed, and even if
    > they are compressed, they may be compressed by any compression method,
    > not just gzip (bzip2 and compress are also common).
    >
    >
    >>>Are there any similar stuff in CGI or related Perl modules?

    >>
    >> There are numerous modules at
    >> http://search.cpan.org/search?query=gzip&mode=all

    >
    > Many web servers also have a compression module, so you may not have to
    > do anything in the CGI script at all.
    >
    > hp

    Compression is done by the web server because you can't compress the HTTP
    request unless the client explicitly tells the web server that it can accept
    compressed data via an ACCEPT header. The header also specifies what
    compression formats the client is able to receive. If you compress the data
    in your CGI script and the client can't uncompress it, the browser will not
    be able to render it.

    IIS 6.0 and above includes a compression module, and there are several
    compression modules available for Apache.
    Thrill5, Nov 16, 2008
    #4
  5. On 2008-11-16 08:55, Thrill5 <> wrote:
    > "Peter J. Holzer" <> wrote in message
    > news:...
    >> On 2008-11-15 16:49, Jürgen Exner <> wrote:
    >>> howa <> wrote:
    >>>>In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    >>>>data to web browsers that support compressed web pages

    [...]
    >>>>Are there any similar stuff in CGI or related Perl modules?
    >>>
    >>> There are numerous modules at
    >>> http://search.cpan.org/search?query=gzip&mode=all

    >>
    >> Many web servers also have a compression module, so you may not have to
    >> do anything in the CGI script at all.


    > Compression is done by the web server because you can't compress the HTTP
    > request unless the client explicitly tells the web server that it can accept
    > compressed data via an ACCEPT header. The header also specifies what
    > compression formats the client is able to receive. If you compress the data
    > in your CGI script and the client can't uncompress it, the browser will not
    > be able to render it.


    The header is passed to the CGI script, so the script can check whether
    the client supports compression just like the server can. Your argument
    makes no sense.

    The real reasons why the server provides this capability are:

    1) It makes little sense to add compression to every script if it can be
    done once for all.

    2) The server can do it also for static files or for scripts which can't
    do it by themselves.

    That said, there may be valid reasons to do it in a script even if the
    server can do it: Most importantly, the script knows more about the data
    and can decide whether it makes sense to compress it.

    hp
    Peter J. Holzer, Nov 16, 2008
    #5
  6. howa

    Bart Lateur Guest

    howa wrote:

    >In PHP, ob_gzhandler() is used to help facilitate sending gz-encoded
    >data to web browsers that support compressed web pages
    >
    >Are there any similar stuff in CGI or related Perl modules?


    In Perl 5.8 and above you can use a gzip IO layer. See
    <http://search.cpan.org/perldoc?PerlIO::gzip>. For more info, see the
    perlfunc docs on binmode and open, and the module docs for PerlIO at
    <http://search.cpan.org/perldoc?PerlIO>.


    --
    Bart.
    Bart Lateur, Nov 16, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    2
    Views:
    1,093
  2. Rajive Narain
    Replies:
    0
    Views:
    1,481
    Rajive Narain
    Sep 18, 2009
  3. Francesco Moi
    Replies:
    2
    Views:
    225
    Gunnar Hjalmarsson
    May 31, 2004
  4. Steve Chapel

    Perl equivalent of PHP and JSP: Mason?

    Steve Chapel, Oct 23, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    195
    GClef
    Oct 24, 2005
  5. Ignoramus6539
    Replies:
    2
    Views:
    192
    Colin McKinnon
    Aug 30, 2006
Loading...

Share This Page