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

Blacklist Windows Browser for transcoding to webp #978

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions