Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Blacklist Windows Browser for transcoding to webp #978

Closed
GoogleCodeExporter opened this issue Apr 6, 2015 · 33 comments
Closed

Blacklist Windows Browser for transcoding to webp #978

GoogleCodeExporter opened this issue Apr 6, 2015 · 33 comments

Comments

@GoogleCodeExporter
Copy link

Webp support is now defined using whitelist and blacklist of browsers' versions 
(\src\pagespeed\kernel\http\user_agent_matcher.cc)

It makes sense to rely on the "image/webp" header and do feature detection 
instead of browser detection.

supports_webp_ variable has specific type FastWildcardGroup that allows to 
return bool values using Match function that takes White/Black lists into 
account.

bool UserAgentMatcher::SupportsWebp function returns 
supports_webp_.Match(user_agent, false);

\src\net\instaweb\rewriter\device_properties.cc contains sample usage of 
HasValue function that is available for headers analysis:

accepts_webp_ =
               request_headers.HasValue(HttpAttributes::kAccept, kContentTypeWebp.mime_type()) ?
                kTrue : kFalse;

So, I think we can use HasValue function to return bool value from SupportsWebp 
function basing on request headers values.

There is also separate webp-related parameter supports_webp_lossless_alpha_ 
that is handled the same way as supports_webp_ now. Not sure is it possible to 
define required value of this parameter using current headers.

There is also the following code:

const char UserAgentMatcher::kTestUserAgentWebP[] = "test-user-agent-webp";
// Note that this must not contain the substring "webp".
const char UserAgentMatcher::kTestUserAgentNoWebP[] = "test-user-agent-no";

but as I can see these variables are not used. However, in case it would be 
necessary to update them, we can place headers values instead of the hardcoded 
strings. This should work as accepted headers of client that does not support 
webp wouldn't contain "webp" substring.

Original issue reported on code.google.com by evgeny.a...@akvelon.com on 29 Aug 2014 at 6:34

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant