[trafficserver] branch 9.0.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9552fe3 Updated ChangeLog 9552fe3 is described below commit 9552fe38f468d3f9584fd981f23e00a797161c53 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:24:12 2020 -0600 Updated ChangeLog --- CHANGELOG-9.0.0 | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG-9.0.0 b/CHANGELOG-9.0.0 index 984007a..de1734c 100644 --- a/CHANGELOG-9.0.0 +++ b/CHANGELOG-9.0.0 @@ -1079,7 +1079,6 @@ Changes with Apache Traffic Server 9.0.0 #7143 - Deprecate cqhv field #7144 - Fix typo in cache docs #7145 - Check VIO availability before acquiring a lock for it - #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7148 - Fix stale pointer due to SSL config reload #7155 - PluginFactory - Remove unused code. #7157 - rc: fixes systemd unit file stopping
[trafficserver] branch 8.1.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 24bca03 Updated ChangeLog 24bca03 is described below commit 24bca0378270ff2e230e22fa21ff7dd718e0cd35 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:20:52 2020 -0600 Updated ChangeLog --- CHANGELOG-8.1.1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-8.1.1 b/CHANGELOG-8.1.1 index f2399e1..76c59bc 100644 --- a/CHANGELOG-8.1.1 +++ b/CHANGELOG-8.1.1 @@ -1,5 +1,8 @@ Changes with Apache Traffic Server 8.1.1 + #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7154 - Fixes H2 toggling using ssl_server_name.yaml #7156 - Fixes garbled logs when using % log tag #7191 - Emits log when OCSP fails to connect to server + #7195 - slice: fix throttle not work (#7008) #7217 - Remove usage of stored ACL record, fix ipallow reload + #7234 - Do not cache Transfer-Encoding header
[trafficserver] branch 9.0.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9552fe3 Updated ChangeLog 9552fe3 is described below commit 9552fe38f468d3f9584fd981f23e00a797161c53 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:24:12 2020 -0600 Updated ChangeLog --- CHANGELOG-9.0.0 | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG-9.0.0 b/CHANGELOG-9.0.0 index 984007a..de1734c 100644 --- a/CHANGELOG-9.0.0 +++ b/CHANGELOG-9.0.0 @@ -1079,7 +1079,6 @@ Changes with Apache Traffic Server 9.0.0 #7143 - Deprecate cqhv field #7144 - Fix typo in cache docs #7145 - Check VIO availability before acquiring a lock for it - #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7148 - Fix stale pointer due to SSL config reload #7155 - PluginFactory - Remove unused code. #7157 - rc: fixes systemd unit file stopping
[trafficserver] branch 9.0.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9552fe3 Updated ChangeLog 9552fe3 is described below commit 9552fe38f468d3f9584fd981f23e00a797161c53 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:24:12 2020 -0600 Updated ChangeLog --- CHANGELOG-9.0.0 | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG-9.0.0 b/CHANGELOG-9.0.0 index 984007a..de1734c 100644 --- a/CHANGELOG-9.0.0 +++ b/CHANGELOG-9.0.0 @@ -1079,7 +1079,6 @@ Changes with Apache Traffic Server 9.0.0 #7143 - Deprecate cqhv field #7144 - Fix typo in cache docs #7145 - Check VIO availability before acquiring a lock for it - #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7148 - Fix stale pointer due to SSL config reload #7155 - PluginFactory - Remove unused code. #7157 - rc: fixes systemd unit file stopping
[trafficserver] branch 8.1.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 24bca03 Updated ChangeLog 24bca03 is described below commit 24bca0378270ff2e230e22fa21ff7dd718e0cd35 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:20:52 2020 -0600 Updated ChangeLog --- CHANGELOG-8.1.1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-8.1.1 b/CHANGELOG-8.1.1 index f2399e1..76c59bc 100644 --- a/CHANGELOG-8.1.1 +++ b/CHANGELOG-8.1.1 @@ -1,5 +1,8 @@ Changes with Apache Traffic Server 8.1.1 + #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7154 - Fixes H2 toggling using ssl_server_name.yaml #7156 - Fixes garbled logs when using % log tag #7191 - Emits log when OCSP fails to connect to server + #7195 - slice: fix throttle not work (#7008) #7217 - Remove usage of stored ACL record, fix ipallow reload + #7234 - Do not cache Transfer-Encoding header
[trafficserver] branch 8.1.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 24bca03 Updated ChangeLog 24bca03 is described below commit 24bca0378270ff2e230e22fa21ff7dd718e0cd35 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:20:52 2020 -0600 Updated ChangeLog --- CHANGELOG-8.1.1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-8.1.1 b/CHANGELOG-8.1.1 index f2399e1..76c59bc 100644 --- a/CHANGELOG-8.1.1 +++ b/CHANGELOG-8.1.1 @@ -1,5 +1,8 @@ Changes with Apache Traffic Server 8.1.1 + #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7154 - Fixes H2 toggling using ssl_server_name.yaml #7156 - Fixes garbled logs when using % log tag #7191 - Emits log when OCSP fails to connect to server + #7195 - slice: fix throttle not work (#7008) #7217 - Remove usage of stored ACL record, fix ipallow reload + #7234 - Do not cache Transfer-Encoding header
[trafficserver] branch 9.0.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9552fe3 Updated ChangeLog 9552fe3 is described below commit 9552fe38f468d3f9584fd981f23e00a797161c53 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:24:12 2020 -0600 Updated ChangeLog --- CHANGELOG-9.0.0 | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG-9.0.0 b/CHANGELOG-9.0.0 index 984007a..de1734c 100644 --- a/CHANGELOG-9.0.0 +++ b/CHANGELOG-9.0.0 @@ -1079,7 +1079,6 @@ Changes with Apache Traffic Server 9.0.0 #7143 - Deprecate cqhv field #7144 - Fix typo in cache docs #7145 - Check VIO availability before acquiring a lock for it - #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7148 - Fix stale pointer due to SSL config reload #7155 - PluginFactory - Remove unused code. #7157 - rc: fixes systemd unit file stopping
[trafficserver] branch 8.1.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 24bca03 Updated ChangeLog 24bca03 is described below commit 24bca0378270ff2e230e22fa21ff7dd718e0cd35 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:20:52 2020 -0600 Updated ChangeLog --- CHANGELOG-8.1.1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-8.1.1 b/CHANGELOG-8.1.1 index f2399e1..76c59bc 100644 --- a/CHANGELOG-8.1.1 +++ b/CHANGELOG-8.1.1 @@ -1,5 +1,8 @@ Changes with Apache Traffic Server 8.1.1 + #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7154 - Fixes H2 toggling using ssl_server_name.yaml #7156 - Fixes garbled logs when using % log tag #7191 - Emits log when OCSP fails to connect to server + #7195 - slice: fix throttle not work (#7008) #7217 - Remove usage of stored ACL record, fix ipallow reload + #7234 - Do not cache Transfer-Encoding header
[trafficserver] branch 9.0.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9552fe3 Updated ChangeLog 9552fe3 is described below commit 9552fe38f468d3f9584fd981f23e00a797161c53 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:24:12 2020 -0600 Updated ChangeLog --- CHANGELOG-9.0.0 | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG-9.0.0 b/CHANGELOG-9.0.0 index 984007a..de1734c 100644 --- a/CHANGELOG-9.0.0 +++ b/CHANGELOG-9.0.0 @@ -1079,7 +1079,6 @@ Changes with Apache Traffic Server 9.0.0 #7143 - Deprecate cqhv field #7144 - Fix typo in cache docs #7145 - Check VIO availability before acquiring a lock for it - #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7148 - Fix stale pointer due to SSL config reload #7155 - PluginFactory - Remove unused code. #7157 - rc: fixes systemd unit file stopping
[trafficserver] branch 8.1.x updated: Updated ChangeLog
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 24bca03 Updated ChangeLog 24bca03 is described below commit 24bca0378270ff2e230e22fa21ff7dd718e0cd35 Author: Leif Hedstrom AuthorDate: Mon Oct 5 19:20:52 2020 -0600 Updated ChangeLog --- CHANGELOG-8.1.1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-8.1.1 b/CHANGELOG-8.1.1 index f2399e1..76c59bc 100644 --- a/CHANGELOG-8.1.1 +++ b/CHANGELOG-8.1.1 @@ -1,5 +1,8 @@ Changes with Apache Traffic Server 8.1.1 + #7147 - slice: check if vio is still valid before calling TSVIODone* on shutdown #7154 - Fixes H2 toggling using ssl_server_name.yaml #7156 - Fixes garbled logs when using % log tag #7191 - Emits log when OCSP fails to connect to server + #7195 - slice: fix throttle not work (#7008) #7217 - Remove usage of stored ACL record, fix ipallow reload + #7234 - Do not cache Transfer-Encoding header
[trafficserver] 03/03: Display more information on exception
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 48b495b84189986dc3966345eadf6b63599eadd2 Author: Bryan Call AuthorDate: Mon Oct 5 17:38:00 2020 -0700 Display more information on exception --- plugins/experimental/webp_transform/ImageTransform.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index c4a6081..a14b9bc 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -100,7 +100,8 @@ public: TSError("ImageMagick++ warning: %s", warning.what()); produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); } catch (Magick::Error ) { - TSError("ImageMagick++ error: %s", error.what()); + TSError("ImageMagick++ error: %s _image_type: %d input_data.length(): %zd", error.what(), (int)_image_type, + input_data.length()); produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); }
[trafficserver] branch webp_to_jpeg created (now 48b495b)
This is an automated email from the ASF dual-hosted git repository. bcall pushed a change to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git. at 48b495b Display more information on exception This branch includes the following new commits: new 9a0f785 Updates to webp_transform to convert webp to jpeg new 5c0558f Updated to handle ImageMagick++ exceptions new 48b495b Display more information on exception The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[trafficserver] 01/03: Updates to webp_transform to convert webp to jpeg
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 9a0f785db5a5ffb370141762b474fe5dbb19a2f5 Author: Bryan Call AuthorDate: Mon Oct 5 12:33:28 2020 -0700 Updates to webp_transform to convert webp to jpeg --- .../experimental/webp_transform/ImageTransform.cc | 102 + 1 file changed, 86 insertions(+), 16 deletions(-) diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index 88d19cd..96ecc73 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -23,10 +23,10 @@ #include "tscpp/api/GlobalPlugin.h" #include "tscpp/api/TransformationPlugin.h" #include "tscpp/api/Logger.h" +#include "tscpp/api/Stat.h" #include -using std::string; using namespace Magick; using namespace atscppapi; @@ -35,12 +35,21 @@ using namespace atscppapi; namespace { GlobalPlugin *plugin; -} + +enum class TransformImageType { webp, jpeg }; + +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 ) : TransformationPlugin(transaction, TransformationPlugin::RESPONSE_TRANSFORMATION) + ImageTransform(Transaction , TransformImageType image_type) +: TransformationPlugin(transaction, TransformationPlugin::RESPONSE_TRANSFORMATION), _image_type(image_type) { TransformationPlugin::registerHook(HOOK_READ_RESPONSE_HEADERS); } @@ -48,8 +57,12 @@ public: void handleReadResponseHeaders(Transaction ) override { -transaction.getServerResponse().getHeaders()["Content-Type"] = "image/webp"; -transaction.getServerResponse().getHeaders()["Vary"] = "Content-Type"; // to have a separate cache entry. +if (_image_type == TransformImageType::webp) { + transaction.getServerResponse().getHeaders()["Content-Type"] = "image/webp"; +} else { + transaction.getServerResponse().getHeaders()["Content-Type"] = "image/jpeg"; +} +transaction.getServerResponse().getHeaders()["Vary"] = "Accpet"; // to have a separate cache entry TS_DEBUG(TAG, "url %s", transaction.getServerRequest().getUrl().getUrlString().c_str()); transaction.resume(); @@ -64,13 +77,21 @@ public: void handleInputComplete() override { -string input_data = _img.str(); +std::string input_data = _img.str(); Blob input_blob(input_data.data(), input_data.length()); Image image; image.read(input_blob); Blob output_blob; -image.magick("WEBP"); +if (_image_type == TransformImageType::webp) { + stat_convert_to_webp.increment(1); + TSDebug(TAG, "Transforming jpeg or png to webp"); + image.magick("WEBP"); +} else { + stat_convert_to_jpeg.increment(1); + TSDebug(TAG, "Transforming wepb to jpeg"); + image.magick("JPEG"); +} image.write(_blob); produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); @@ -81,6 +102,7 @@ public: private: std::stringstream _img; + TransformImageType _image_type; }; class GlobalHookPlugin : public GlobalPlugin @@ -90,16 +112,40 @@ public: void handleReadResponseHeaders(Transaction ) override { -string ctype = transaction.getServerResponse().getHeaders().values("Content-Type"); -string user_agent = transaction.getServerRequest().getHeaders().values("User-Agent"); -string accept = transaction.getServerRequest().getHeaders().values("Accept"); +// This method tries to optimize the amount of string searching at the expense of double checking some of the booleans + +std::string ctype = transaction.getServerResponse().getHeaders().values("Content-Type"); -bool webp_supported = accept.find("image/webp") != string::npos || user_agent.find("Chrome") != string::npos; -bool image_format = ctype.find("jpeg") != string::npos || ctype.find("png") != string::npos; +// Test to if in this transaction we might want to convert jpeg or png to webp +bool transaction_convert_to_wepb = false; +if (config_convert_to_webp == true) { + transaction_convert_to_wepb = ctype.find("image/jpeg") != std::string::npos || ctype.find("image/png") != std::string::npos; +} -if (webp_supported && image_format) { - TS_DEBUG(TAG, "Content type is either jpeg or png. Converting to webp"); - transaction.addPlugin(new ImageTransform(transaction)); +// Test to if in this transaction we might want to convert webp to jpeg +bool transaction_convert_to_jpeg = false; +if (config_convert_to_jpeg == true && transaction_convert_to_wepb == false) { + transaction_convert_to_jpeg = ctype.find("image/webp") !=
[trafficserver] 02/03: Updated to handle ImageMagick++ exceptions
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 5c0558f1f58c239236a8777b5dd89ea404f6d0fa Author: Bryan Call AuthorDate: Mon Oct 5 16:34:40 2020 -0700 Updated to handle ImageMagick++ exceptions --- doc/admin-guide/plugins/webp_transform.en.rst | 7 +++-- .../experimental/webp_transform/ImageTransform.cc | 33 ++ plugins/experimental/webp_transform/Makefile.inc | 12 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/doc/admin-guide/plugins/webp_transform.en.rst b/doc/admin-guide/plugins/webp_transform.en.rst index 1fa2262..f729a59 100644 --- a/doc/admin-guide/plugins/webp_transform.en.rst +++ b/doc/admin-guide/plugins/webp_transform.en.rst @@ -22,16 +22,17 @@ Webp Transform Plugin * -This plugin converts jpeg and png images and transforms them into webp format. +This plugin converts jpeg and png images and transforms them into webp format for browsers that support webp. +Also, the plugin converts webp images and transforms them to jpeg for browsers that don't support webp All response with content-type 'image/jpeg' or 'image/png' will go through the transform. -Content-type is changed to 'image/webp' on successful transformation. +Content-type is changed to 'image/webp' or 'image/jpeg' on successful transformation. Installation Add the following line to :file:`plugin.config`:: -webp_transform.so +webp_transform.so [convert_to_jpeg,convert_to_webp] Note diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index 96ecc73..c4a6081 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -80,20 +80,29 @@ public: std::string input_data = _img.str(); Blob input_blob(input_data.data(), input_data.length()); Image image; -image.read(input_blob); -Blob output_blob; -if (_image_type == TransformImageType::webp) { - stat_convert_to_webp.increment(1); - TSDebug(TAG, "Transforming jpeg or png to webp"); - image.magick("WEBP"); -} else { - stat_convert_to_jpeg.increment(1); - TSDebug(TAG, "Transforming wepb to jpeg"); - image.magick("JPEG"); +try { + image.read(input_blob); + + Blob output_blob; + if (_image_type == TransformImageType::webp) { +stat_convert_to_webp.increment(1); +TSDebug(TAG, "Transforming jpeg or png to webp"); +image.magick("WEBP"); + } else { +stat_convert_to_jpeg.increment(1); +TSDebug(TAG, "Transforming wepb to jpeg"); +image.magick("JPEG"); + } + image.write(_blob); + produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); +} catch (Magick::Warning ) { + TSError("ImageMagick++ warning: %s", warning.what()); + produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); +} catch (Magick::Error ) { + TSError("ImageMagick++ error: %s", error.what()); + produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); } -image.write(_blob); -produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); setOutputComplete(); } diff --git a/plugins/experimental/webp_transform/Makefile.inc b/plugins/experimental/webp_transform/Makefile.inc index fd24dab..a7423bc 100644 --- a/plugins/experimental/webp_transform/Makefile.inc +++ b/plugins/experimental/webp_transform/Makefile.inc @@ -15,18 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -experimental_webp_transform_WebpTransform_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMAGICKCPP_CFLAGS) -experimental_webp_transform_WebpTransform_la_CXXFLAGS = $(AM_CXXFLAGS) +experimental_webp_transform_webp_transform_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMAGICKCPP_CFLAGS) +experimental_webp_transform_webp_transform_la_CXXFLAGS = $(AM_CXXFLAGS) -pkglib_LTLIBRARIES += experimental/webp_transform/WebpTransform.la +pkglib_LTLIBRARIES += experimental/webp_transform/webp_transform.la -experimental_webp_transform_WebpTransform_la_SOURCES = \ +experimental_webp_transform_webp_transform_la_SOURCES = \ experimental/webp_transform/ImageTransform.cc -experimental_webp_transform_WebpTransform_la_LDFLAGS = \ +experimental_webp_transform_webp_transform_la_LDFLAGS = \ $(AM_LDFLAGS) \ -L$(top_builddir)/src/tscpp/api -experimental_webp_transform_WebpTransform_la_LIBADD = \ +experimental_webp_transform_webp_transform_la_LIBADD = \ -ltscppapi \ $(LIBMAGICKCPP_LIBS)
[trafficserver] branch webp_to_jpeg created (now 48b495b)
This is an automated email from the ASF dual-hosted git repository. bcall pushed a change to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git. at 48b495b Display more information on exception This branch includes the following new commits: new 9a0f785 Updates to webp_transform to convert webp to jpeg new 5c0558f Updated to handle ImageMagick++ exceptions new 48b495b Display more information on exception The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[trafficserver] 03/03: Display more information on exception
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 48b495b84189986dc3966345eadf6b63599eadd2 Author: Bryan Call AuthorDate: Mon Oct 5 17:38:00 2020 -0700 Display more information on exception --- plugins/experimental/webp_transform/ImageTransform.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index c4a6081..a14b9bc 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -100,7 +100,8 @@ public: TSError("ImageMagick++ warning: %s", warning.what()); produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); } catch (Magick::Error ) { - TSError("ImageMagick++ error: %s", error.what()); + TSError("ImageMagick++ error: %s _image_type: %d input_data.length(): %zd", error.what(), (int)_image_type, + input_data.length()); produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); }
[trafficserver] 01/03: Updates to webp_transform to convert webp to jpeg
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 9a0f785db5a5ffb370141762b474fe5dbb19a2f5 Author: Bryan Call AuthorDate: Mon Oct 5 12:33:28 2020 -0700 Updates to webp_transform to convert webp to jpeg --- .../experimental/webp_transform/ImageTransform.cc | 102 + 1 file changed, 86 insertions(+), 16 deletions(-) diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index 88d19cd..96ecc73 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -23,10 +23,10 @@ #include "tscpp/api/GlobalPlugin.h" #include "tscpp/api/TransformationPlugin.h" #include "tscpp/api/Logger.h" +#include "tscpp/api/Stat.h" #include -using std::string; using namespace Magick; using namespace atscppapi; @@ -35,12 +35,21 @@ using namespace atscppapi; namespace { GlobalPlugin *plugin; -} + +enum class TransformImageType { webp, jpeg }; + +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 ) : TransformationPlugin(transaction, TransformationPlugin::RESPONSE_TRANSFORMATION) + ImageTransform(Transaction , TransformImageType image_type) +: TransformationPlugin(transaction, TransformationPlugin::RESPONSE_TRANSFORMATION), _image_type(image_type) { TransformationPlugin::registerHook(HOOK_READ_RESPONSE_HEADERS); } @@ -48,8 +57,12 @@ public: void handleReadResponseHeaders(Transaction ) override { -transaction.getServerResponse().getHeaders()["Content-Type"] = "image/webp"; -transaction.getServerResponse().getHeaders()["Vary"] = "Content-Type"; // to have a separate cache entry. +if (_image_type == TransformImageType::webp) { + transaction.getServerResponse().getHeaders()["Content-Type"] = "image/webp"; +} else { + transaction.getServerResponse().getHeaders()["Content-Type"] = "image/jpeg"; +} +transaction.getServerResponse().getHeaders()["Vary"] = "Accpet"; // to have a separate cache entry TS_DEBUG(TAG, "url %s", transaction.getServerRequest().getUrl().getUrlString().c_str()); transaction.resume(); @@ -64,13 +77,21 @@ public: void handleInputComplete() override { -string input_data = _img.str(); +std::string input_data = _img.str(); Blob input_blob(input_data.data(), input_data.length()); Image image; image.read(input_blob); Blob output_blob; -image.magick("WEBP"); +if (_image_type == TransformImageType::webp) { + stat_convert_to_webp.increment(1); + TSDebug(TAG, "Transforming jpeg or png to webp"); + image.magick("WEBP"); +} else { + stat_convert_to_jpeg.increment(1); + TSDebug(TAG, "Transforming wepb to jpeg"); + image.magick("JPEG"); +} image.write(_blob); produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); @@ -81,6 +102,7 @@ public: private: std::stringstream _img; + TransformImageType _image_type; }; class GlobalHookPlugin : public GlobalPlugin @@ -90,16 +112,40 @@ public: void handleReadResponseHeaders(Transaction ) override { -string ctype = transaction.getServerResponse().getHeaders().values("Content-Type"); -string user_agent = transaction.getServerRequest().getHeaders().values("User-Agent"); -string accept = transaction.getServerRequest().getHeaders().values("Accept"); +// This method tries to optimize the amount of string searching at the expense of double checking some of the booleans + +std::string ctype = transaction.getServerResponse().getHeaders().values("Content-Type"); -bool webp_supported = accept.find("image/webp") != string::npos || user_agent.find("Chrome") != string::npos; -bool image_format = ctype.find("jpeg") != string::npos || ctype.find("png") != string::npos; +// Test to if in this transaction we might want to convert jpeg or png to webp +bool transaction_convert_to_wepb = false; +if (config_convert_to_webp == true) { + transaction_convert_to_wepb = ctype.find("image/jpeg") != std::string::npos || ctype.find("image/png") != std::string::npos; +} -if (webp_supported && image_format) { - TS_DEBUG(TAG, "Content type is either jpeg or png. Converting to webp"); - transaction.addPlugin(new ImageTransform(transaction)); +// Test to if in this transaction we might want to convert webp to jpeg +bool transaction_convert_to_jpeg = false; +if (config_convert_to_jpeg == true && transaction_convert_to_wepb == false) { + transaction_convert_to_jpeg = ctype.find("image/webp") !=
[trafficserver] 02/03: Updated to handle ImageMagick++ exceptions
This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch webp_to_jpeg in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 5c0558f1f58c239236a8777b5dd89ea404f6d0fa Author: Bryan Call AuthorDate: Mon Oct 5 16:34:40 2020 -0700 Updated to handle ImageMagick++ exceptions --- doc/admin-guide/plugins/webp_transform.en.rst | 7 +++-- .../experimental/webp_transform/ImageTransform.cc | 33 ++ plugins/experimental/webp_transform/Makefile.inc | 12 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/doc/admin-guide/plugins/webp_transform.en.rst b/doc/admin-guide/plugins/webp_transform.en.rst index 1fa2262..f729a59 100644 --- a/doc/admin-guide/plugins/webp_transform.en.rst +++ b/doc/admin-guide/plugins/webp_transform.en.rst @@ -22,16 +22,17 @@ Webp Transform Plugin * -This plugin converts jpeg and png images and transforms them into webp format. +This plugin converts jpeg and png images and transforms them into webp format for browsers that support webp. +Also, the plugin converts webp images and transforms them to jpeg for browsers that don't support webp All response with content-type 'image/jpeg' or 'image/png' will go through the transform. -Content-type is changed to 'image/webp' on successful transformation. +Content-type is changed to 'image/webp' or 'image/jpeg' on successful transformation. Installation Add the following line to :file:`plugin.config`:: -webp_transform.so +webp_transform.so [convert_to_jpeg,convert_to_webp] Note diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc index 96ecc73..c4a6081 100644 --- a/plugins/experimental/webp_transform/ImageTransform.cc +++ b/plugins/experimental/webp_transform/ImageTransform.cc @@ -80,20 +80,29 @@ public: std::string input_data = _img.str(); Blob input_blob(input_data.data(), input_data.length()); Image image; -image.read(input_blob); -Blob output_blob; -if (_image_type == TransformImageType::webp) { - stat_convert_to_webp.increment(1); - TSDebug(TAG, "Transforming jpeg or png to webp"); - image.magick("WEBP"); -} else { - stat_convert_to_jpeg.increment(1); - TSDebug(TAG, "Transforming wepb to jpeg"); - image.magick("JPEG"); +try { + image.read(input_blob); + + Blob output_blob; + if (_image_type == TransformImageType::webp) { +stat_convert_to_webp.increment(1); +TSDebug(TAG, "Transforming jpeg or png to webp"); +image.magick("WEBP"); + } else { +stat_convert_to_jpeg.increment(1); +TSDebug(TAG, "Transforming wepb to jpeg"); +image.magick("JPEG"); + } + image.write(_blob); + produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); +} catch (Magick::Warning ) { + TSError("ImageMagick++ warning: %s", warning.what()); + produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); +} catch (Magick::Error ) { + TSError("ImageMagick++ error: %s", error.what()); + produce(std::string_view(reinterpret_cast(input_blob.data()), input_blob.length())); } -image.write(_blob); -produce(std::string_view(reinterpret_cast(output_blob.data()), output_blob.length())); setOutputComplete(); } diff --git a/plugins/experimental/webp_transform/Makefile.inc b/plugins/experimental/webp_transform/Makefile.inc index fd24dab..a7423bc 100644 --- a/plugins/experimental/webp_transform/Makefile.inc +++ b/plugins/experimental/webp_transform/Makefile.inc @@ -15,18 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -experimental_webp_transform_WebpTransform_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMAGICKCPP_CFLAGS) -experimental_webp_transform_WebpTransform_la_CXXFLAGS = $(AM_CXXFLAGS) +experimental_webp_transform_webp_transform_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMAGICKCPP_CFLAGS) +experimental_webp_transform_webp_transform_la_CXXFLAGS = $(AM_CXXFLAGS) -pkglib_LTLIBRARIES += experimental/webp_transform/WebpTransform.la +pkglib_LTLIBRARIES += experimental/webp_transform/webp_transform.la -experimental_webp_transform_WebpTransform_la_SOURCES = \ +experimental_webp_transform_webp_transform_la_SOURCES = \ experimental/webp_transform/ImageTransform.cc -experimental_webp_transform_WebpTransform_la_LDFLAGS = \ +experimental_webp_transform_webp_transform_la_LDFLAGS = \ $(AM_LDFLAGS) \ -L$(top_builddir)/src/tscpp/api -experimental_webp_transform_WebpTransform_la_LIBADD = \ +experimental_webp_transform_webp_transform_la_LIBADD = \ -ltscppapi \ $(LIBMAGICKCPP_LIBS)
[trafficserver] branch 8.1.x updated: Do not cache Transfer-Encoding header (#7234)
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/8.1.x by this push: new 043ba6e Do not cache Transfer-Encoding header (#7234) 043ba6e is described below commit 043ba6ee8270b6050398344e942e9168a5243d06 Author: Vijay Mamidi AuthorDate: Sun Oct 4 19:39:49 2020 -0700 Do not cache Transfer-Encoding header (#7234) (cherry picked from commit 788224fd35c714ce89c23922ce9d9f770db25ea4) --- proxy/http/HttpTransact.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index e5c97c9..82da476 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -4762,9 +4762,9 @@ HttpTransact::merge_response_header_with_cached_header(HTTPHdr *cached_header, H continue; } / -// dont cache content-length field // +// dont cache content-length field and transfer encoding // / -if (name == MIME_FIELD_CONTENT_LENGTH) { +if (name == MIME_FIELD_CONTENT_LENGTH || name == MIME_FIELD_TRANSFER_ENCODING) { continue; } /
[trafficserver] branch 9.0.x updated: Do not cache Transfer-Encoding header (#7234)
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/9.0.x by this push: new bf6c0a9 Do not cache Transfer-Encoding header (#7234) bf6c0a9 is described below commit bf6c0a9b60535b56afd089941859f77d4e101c2c Author: Vijay Mamidi AuthorDate: Sun Oct 4 19:39:49 2020 -0700 Do not cache Transfer-Encoding header (#7234) (cherry picked from commit 788224fd35c714ce89c23922ce9d9f770db25ea4) --- proxy/http/HttpTransact.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index a990c9c..79cca0e 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -4991,9 +4991,9 @@ HttpTransact::merge_response_header_with_cached_header(HTTPHdr *cached_header, H continue; } / -// dont cache content-length field // +// dont cache content-length field and transfer encoding // / -if (name == MIME_FIELD_CONTENT_LENGTH) { +if (name == MIME_FIELD_CONTENT_LENGTH || name == MIME_FIELD_TRANSFER_ENCODING) { continue; } /
[trafficserver] branch master updated (788224f -> ab37864)
This is an automated email from the ASF dual-hosted git repository. shinrich pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git. from 788224f Do not cache Transfer-Encoding header (#7234) add ab37864 Stop crash on disk failure (#7218) No new revisions were added by this update. Summary of changes: iocore/cache/Cache.cc | 75 --- 1 file changed, 48 insertions(+), 27 deletions(-)