You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 21, 2023. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
evgeny.a...@akvelon.com
on 29 Aug 2014 at 6:34The text was updated successfully, but these errors were encountered: