PHP's ob_gzhandler equivalent in Perl ?

H

howa

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.
 
P

Peter J. Holzer

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).


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

hp
 
T

Thrill5

Peter J. Holzer said:
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").


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).



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.
 
P

Peter J. Holzer

Peter J. Holzer said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top