randall commented on a change in pull request #8005:
URL: https://github.com/apache/trafficserver/pull/8005#discussion_r660857978
##########
File path: plugins/experimental/webp_transform/ImageTransform.cc
##########
@@ -35,21 +35,40 @@ using namespace atscppapi;
namespace
{
GlobalPlugin *plugin;
-}
+
+enum class ImageEncoding { webp, jpeg, png, unknown };
+
+bool config_convert_to_webp = false;
+bool config_convert_to_jpeg = false;
+
+Stat stat_convert_to_webp;
+Stat stat_convert_to_jpeg;
+} // namespace
class ImageTransform : public TransformationPlugin
{
public:
- ImageTransform(Transaction &transaction) : TransformationPlugin(transaction,
TransformationPlugin::RESPONSE_TRANSFORMATION)
+ ImageTransform(Transaction &transaction, ImageEncoding input_image_type,
ImageEncoding transform_image_type)
+ : TransformationPlugin(transaction,
TransformationPlugin::RESPONSE_TRANSFORMATION),
+ _input_image_type(input_image_type),
+ _transform_image_type(transform_image_type)
{
TransformationPlugin::registerHook(HOOK_READ_RESPONSE_HEADERS);
}
void
handleReadResponseHeaders(Transaction &transaction) override
{
- transaction.getServerResponse().getHeaders()["Content-Type"] =
"image/webp";
- transaction.getServerResponse().getHeaders()["Vary"] =
"Content-Type"; // to have a separate cache entry.
+ if (_transform_image_type == ImageEncoding::webp) {
Review comment:
would this be better as a switch on _transform_image_type ? or just a
series of else if?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]