bneradt commented on code in PR #12505:
URL: https://github.com/apache/trafficserver/pull/12505#discussion_r2353015972


##########
plugins/compress/configuration.cc:
##########
@@ -190,6 +191,18 @@ HostConfiguration::is_status_code_compressible(const 
TSHttpStatus status_code) c
   return it != compressible_status_codes_.end();
 }
 
+static std::string_view
+strip_params(std::string_view v)
+{
+  if (auto pos = v.find(';'); pos != std::string_view::npos) {
+    v = v.substr(0, pos);
+  }
+  // trim trailing spaces
+  while (!v.empty() && isspace(static_cast<unsigned char>(v.back())))
+    v.remove_suffix(1);
+  return v;

Review Comment:
   Let's refactor this to use swoc::TextView. I think take_prefix_at and rtrim 
should be useful here.



##########
plugins/compress/configuration.h:
##########
@@ -58,10 +58,22 @@ class HostConfiguration : private atscppapi::noncopyable
       remove_accept_encoding_(false),
       flush_(false),
       compression_algorithms_(ALGORITHM_GZIP),
-      minimum_content_length_(1024)
+      minimum_content_length_(1024),
+      content_type_ignore_parameters_(false)
   {
   }
 
+  bool
+  content_type_ignore_parameters()
+  {
+    return content_type_ignore_parameters_;
+  }

Review Comment:
   `const`



##########
tests/gold_tests/pluginTest/compress/compress-content-type-params.test.py:
##########
@@ -0,0 +1,72 @@
+'''
+Test compress plugin matching with Content-Type parameters
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.Summary = '''
+Verify content_type_ignore_parameters affects compressible-content-type 
matching
+'''
+
+Test.SkipUnless(Condition.PluginExists('compress.so'))
+
+
+class CompressPluginContentTypeParamsTest:
+    replayFile = "replay/compress-content-type-params.replay.yaml"
+
+    def __init__(self):
+        self.setupOriginServer()
+        self.setupTS()
+
+    def setupOriginServer(self):
+        self.server = Test.MakeVerifierServerProcess("verifier-server", 
self.replayFile)
+
+    def setupTS(self):
+        self.ts = Test.MakeATSProcess("ts")
+        self.ts.Disk.records_config.update(
+            {
+                "proxy.config.diags.debug.enabled": 1,
+                "proxy.config.diags.debug.tags": "http|compress",
+                "proxy.config.http.insert_response_via_str": 2,
+            })
+
+        # Copy configs into the run directory
+        self.ts.Setup.Copy("etc/ignore-params-false.config")
+        self.ts.Setup.Copy("etc/ignore-params-true.config")
+
+        self.ts.Disk.remap_config.AddLines(
+            {
+                f"""
+map /ignore-params-false/ http://127.0.0.1:{self.server.Variables.http_port}/ \
+    @plugin=compress.so \
+    @pparam={Test.RunDirectory}/ignore-params-false.config
+map /ignore-params-true/ http://127.0.0.1:{self.server.Variables.http_port}/ \
+    @plugin=compress.so \
+    @pparam={Test.RunDirectory}/ignore-params-true.config
+"""
+            })

Review Comment:
   Add lines more naturally takes a list of lines. Here's an example from 
another test:
   
   ```python
   tm.Disk.remap_config.AddLines(
       [
           f"map http://alpha.ex http://alpha.ex:{pv_port}";,
           f"map http://bravo.ex http://bravo.ex:{pv_port}";,
           f"map http://charlie.ex http://charlie.ex:{pv_port}";,
           f"map http://delta.ex http://delta.ex:{pv_port}";,
       ])
   ```



-- 
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]

Reply via email to