SolidWallOfCode commented on a change in pull request #7657:
URL: https://github.com/apache/trafficserver/pull/7657#discussion_r607364887



##########
File path: proxy/http/HttpTransact.cc
##########
@@ -6572,16 +6585,29 @@ HttpTransact::will_this_request_self_loop(State *s)
       int via_len;
       const char *via_string = via_field->value_get(&via_len);
 
-      if (via_string && ptr_len_str(via_string, via_len, uuid)) {
-        SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED);
-        TxnDebug("http_transact", "Incoming via: %.*s has (%s[%s] (%s))", 
via_len, via_string, s->http_config_param->proxy_hostname,
-                 uuid, s->http_config_param->proxy_request_via_string);
-        build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Multi-Hop Cycle 
Detected", "request#cycle_detected");
-        return true;
+      if (via_string) {
+        char *current = (char *)via_string;
+        int len       = via_len;
+        TxnDebug("http_transact", "Incoming via: \"%.*s\" --has-- (%s[%s] 
(%s))", via_len, via_string,
+                 s->http_config_param->proxy_hostname, uuid, 
s->http_config_param->proxy_request_via_string);
+        while (char *result = (char *)ptr_len_str(current, len, uuid)) {

Review comment:
       Maybe more like this, for switching to modern C++?
   ```
   std::string_view current { via_field->value_get() };
   std::string_view uuid { Machine::instance()->uuid};
   std::string_view::size offset;
   while (count <= max_proxy_cycles && std::string_view::npos != (offset = 
current.find(uuid))) {
     current.remove_prefix(offset);
     ++count;
   }
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to