On Wed, Mar 26, 2003 at 01:08:17AM +0100, Philippe 'BooK' Bruhat wrote:
> Having a deflate filter
> would allow the proxy to request compressed responses, and
> decrompress/filter/recompress, or simply decompress/filter if the client
> doesn't support deflate (any flavour) but the origin server does.
> 
> Oh. I guess that LWP::UserAgent knows (or will know) better, and
> probably uncompress the flow before passing it back to the script.

  The code I added to Net::HTTP requires a construct time option to 
enable automatic compression and decompression ("WantCompression" => 1).
That way only applications that want it can request this automatic...
  In order to do it I need to mess with the 'Accept-Encoding:' header 
to advertise support... I'm should think about what to do if someone
already specified this header.


  For your application it would make more sense for you to not use
this WantCompression flag, because you won't want Net::HTTP decompressing 
stuff you could sent to the clients compressed.

  You can request compressed data via sending a
'Accept-Encoding: gzip, deflate', then handle the response directly.


> After grepping a little in /usr/share/perl5, I found that
> Net::HTTP::Methods works with deflate/gzip (and Compress::ZLib, what
> a surprise), but LWP seems to use its own LWP::Protocol::* modules. I
> suppose that means that LWP does not supports deflate/gzip?

  Yes... tricky.  LWP uses Net::HTTP... this is because
LWP::Protocol::http is derived from Net::HTTP, (is a subclass of).

if you look at the end of LWP/Protocol/http.pm there is the following:
===
  @ISA = qw(LWP::Protocol::http::SocketMethods Net::HTTP);
===

also if you look at the _new_socket, method:
===
    my $sock = $self->socket_class->new(PeerAddr => $host,
                                        PeerPort => $port,
                                        Proto    => 'tcp',
                                        Timeout  => $timeout,
                                        KeepAlive => !!$conn_cache,
                                        SendTE    => 1,
                                        $self->_extra_sock_opts($host, $port),
                                       );
===

  This call invokes the Net::HTTP method that I've been talking so much
about... which is why the patches I sent change the SendTE to off, and
enable WantCompression.  ;)

    TTFN,
      Mike Simons

Reply via email to