Show quoted text> I understand your point that libraries should not transparently decode
> content, but I'm reluctant to break everybody's code just for correctness.
I don't think that this change will break much (any?) code. Thats why:
There are two cases (at least which I know) when server sends
Content-Encoding header.
1. Request has header Accept-Encoding.
2. Requesting ".gz" file from apache.
In first case if developer setting Accept-Encoding header, developer
knows what he is doing and he ready to get response with encoded
content. In this case transparent decoding even make situation confusing
(expected encoded content but get decoded).
In second case, transparent decoding, I guess, is not the thing which
developer expected. And I'm doubt that someone relies on such behavior
(I think if developer request some file with .gz suffix it expect to get
gzipped data but not already unzipped file).
In other cases (when niether Accept-Encoding header is set nor .gz file
requested) developer does not expect to get encoded content (and
developer should not get it).
Current implementation of PoCoCl::HTTP is adding Accept-Encoding: gzip
to request and trying to handle response with Content-Encoding.
Actually PoCoCl::HTTP is trying to deceive client program. Even if
program do not want to use compression the PoCoCl::HTTP request a
document with compression and decompress it for program to present it as
uncompressed.
I want to emphasize that http server does not compress document if it is
not asked for. So if Accept-Encoding is not set, server will not respond
with encoded content and Content-Encoding header (The exception is when
document already compressed, like static gzipped file, in this case
server has no other option just like to send content as is and set
Content-Type and Content-Encoding. But it is not the case where
transpared decompression is expected).
So I think the only consequence of disabling transparent compression is
increased consumed bandwitdh (compression is requested implicitly by
PoCoCl::HTTP, but after disabling transparent compression, compression
will be used only if client application requested it).
By the way, I see Transfer-Encoding handling code exists in
PoCoCl::HTTP, but a) compression filters is commented out in
te_possible_filters b) TE: header is not added to request. If this code
works, it seems it is not difficult to enable transparent compression on
this level?
PS. I thought out some improvement to current workaround. Currently
PoCoCl::HTTP does not set Accept-Encoding header if user set it already.
But if it sees Content-Encoding, content decoded is unconditionally (no
matter who set Accept-Encoding user or library).
It is possible to make some flag in PoCoCl::HTTP::Request that
Accept-Encoding was set by library, and handle Content-Encoding only if
flag is set. Thus if user set Accept-Encoding header, user get
"untouched" content.
With this change compatibilty (from application developer's perspective)
with LWP::UserAgent will be full.
Show quoted text> I think the best way to remove the feature would be to phase it out over
> several releases. Here's the plan I suggested to POE's mailing list.
> What do you think?
As I explained above, I think this change does not hit most of users. So
probably it is ok to disable transparent decoding by default. And if
this will breake some code (either make fixes to work with this code, or
revert change and implement this change by phases like you proposed).
Show quoted text> 1a. Only decode content for text/* that is gzip encoded. All other
> content would be passed through unchanged.
>
> 1b. Add a new option to do transparent decoding, and leave it on by
default.
Show quoted text>
> 2. Later, throw a warning if the option is turned on. Remind the
> application developer to use decoded_content() if they want decoded
content.
Show quoted text>
> 3. Later, throw a hard error (and reminder) at the developer if the
> option is enabled.
>
> 4. Later, remove the transparent decoding feature and option altogether.
>
> The option lets developers explicitly state what they want, and then
> deprecation guides them into the new behavior.