[
https://issues.apache.org/jira/browse/KNOX-3035?focusedWorklogId=988192&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-988192
]
ASF GitHub Bot logged work on KNOX-3035:
----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Oct/25 13:52
Start Date: 21/Oct/25 13:52
Worklog Time Spent: 10m
Work Description: smolnar82 commented on code in PR #1101:
URL: https://github.com/apache/knox/pull/1101#discussion_r2448423357
##########
gateway-spi/src/main/java/org/apache/knox/gateway/util/GroupUtils.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+package org.apache.knox.gateway.util;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class GroupUtils {
+
+ public static List<String> getGroupStrings(Collection<String> groupNames,
final int lengthLimit, final int sizeLimitBytes) {
+ if (groupNames.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ if (sizeLimitBytes > 0) {
+ return getGroupStringsBySize(groupNames, sizeLimitBytes);
+ } else {
+ return getGroupStringsByLength(groupNames, lengthLimit);
+ }
+ }
+
+ private static List<String> getGroupStringsBySize(Collection<String>
groupNames, int sizeLimitBytes) {
+ final List<String> groupStrings = new ArrayList<>();
+ StringBuilder sb = new StringBuilder();
+ int currentSize = 0; // UTF-8 byte count
+
+ for (String groupName : groupNames) {
+ int commaBytes = sb.length() > 0 ? 1 : 0; // comma between groups
+ int groupBytes = groupName.getBytes(StandardCharsets.UTF_8).length;
+ int projectedSize = currentSize + commaBytes + groupBytes;
+
+ if (projectedSize > sizeLimitBytes) {
+ groupStrings.add(sb.toString());
+ sb = new StringBuilder();
+ currentSize = 0;
+ }
+
+ currentSize = addCommaIfNeeded(sb, currentSize);
+ sb.append(groupName);
+ currentSize += groupBytes;
+ }
+
+ if (sb.length() > 0) {
+ groupStrings.add(sb.toString());
Review Comment:
```
$ curl -iku admin:admin-password
https://localhost:8443/gateway/sandbox/auth/api/v1/pre
HTTP/1.1 200 OK
Date: Tue, 21 Oct 2025 13:50:49 GMT
Set-Cookie: KNOXSESSIONID=node01t08m403se7471u3f5wabrrrba4.node0;
Path=/gateway/sandbox; Secure; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/gateway/sandbox; Max-Age=0;
Expires=Mon, 20-Oct-2025 13:50:49 GMT; SameSite=lax
X-Knox-Actor-ID: admin
X-Knox-Actor-Groups-1:
X-Knox-Actor-Groups-2: longGroupN?me91
X-Knox-Actor-Groups-3: longGroupN?me92
X-Knox-Actor-Groups-4: longGroupN?me90
X-Knox-Actor-Groups-5: longGroupN?me95
X-Knox-Actor-Groups-6: longGroupN?me96
X-Knox-Actor-Groups-7: longGroupN?me93
X-Knox-Actor-Groups-8: longGroupN?me94
X-Knox-Actor-Groups-9: longGroupN?me99
X-Knox-Actor-Groups-10: longGroupN?me11
X-Knox-Actor-Groups-11: longGroupN?me12
X-Knox-Actor-Groups-12: longGroupN?me97
X-Knox-Actor-Groups-13: longGroupN?me10
X-Knox-Actor-Groups-14: longGroupN?me98
X-Knox-Actor-Groups-15: longGroupN?me15
X-Knox-Actor-Groups-16: longGroupN?me16
X-Knox-Actor-Groups-17: longGroupN?me13
X-Knox-Actor-Groups-18: longGroupN?me14
X-Knox-Actor-Groups-19: longGroupN?me19
X-Knox-Actor-Groups-20: longGroupN?me17
X-Knox-Actor-Groups-21: longGroupN?me18
X-Knox-Actor-Groups-22: longGroupN?me80
X-Knox-Actor-Groups-23: longGroupN?me81
X-Knox-Actor-Groups-24: longGroupN?me84
X-Knox-Actor-Groups-25: longGroupN?me85
X-Knox-Actor-Groups-26: longGroupN?me82
X-Knox-Actor-Groups-27: longGroupN?me83
X-Knox-Actor-Groups-28: longGroupN?me88
X-Knox-Actor-Groups-29: longGroupN?me89
X-Knox-Actor-Groups-30: longGroupN?me86
X-Knox-Actor-Groups-31: longGroupN?me87
X-Knox-Actor-Groups-32: longGroupN?me30
X-Knox-Actor-Groups-33: longGroupN?me33
X-Knox-Actor-Groups-34: longGroupN?me34
X-Knox-Actor-Groups-35: longGroupN?me31
X-Knox-Actor-Groups-36: longGroupN?me32
X-Knox-Actor-Groups-37: longGroupN?me37
X-Knox-Actor-Groups-38: longGroupN?me38
X-Knox-Actor-Groups-39: longGroupN?me35
X-Knox-Actor-Groups-40: longGroupN?me36
X-Knox-Actor-Groups-41: longGroupN?me39
X-Knox-Actor-Groups-42: longGroupN?me22
X-Knox-Actor-Groups-43: longGroupN?me23
X-Knox-Actor-Groups-44: longGroupN?me20
X-Knox-Actor-Groups-45: longGroupN?me21
X-Knox-Actor-Groups-46: longGroupN?me26
X-Knox-Actor-Groups-47: longGroupN?me27
X-Knox-Actor-Groups-48: longGroupN?me24
X-Knox-Actor-Groups-49: longGroupN?me25
X-Knox-Actor-Groups-50: longGroupN?me28
X-Knox-Actor-Groups-51: longGroupN?me29
X-Knox-Actor-Groups-52: longGroupN?me51
X-Knox-Actor-Groups-53: longGroupN?me52
X-Knox-Actor-Groups-54: longGroupN?me50
X-Knox-Actor-Groups-55: longGroupN?me55
X-Knox-Actor-Groups-56: longGroupN?me56
X-Knox-Actor-Groups-57: longGroupN?me53
X-Knox-Actor-Groups-58: longGroupN?me54
X-Knox-Actor-Groups-59: longGroupN?me59
X-Knox-Actor-Groups-60: longGroupN?me57
X-Knox-Actor-Groups-61: longGroupN?me58
X-Knox-Actor-Groups-62: longGroupN?me40
X-Knox-Actor-Groups-63: longGroupN?me41
X-Knox-Actor-Groups-64: longGroupN?me44
X-Knox-Actor-Groups-65: longGroupN?me45
X-Knox-Actor-Groups-66: longGroupN?me42
X-Knox-Actor-Groups-67: longGroupN?me43
X-Knox-Actor-Groups-68: longGroupN?me48
X-Knox-Actor-Groups-69: longGroupN?me49
X-Knox-Actor-Groups-70: longGroupN?me46
X-Knox-Actor-Groups-71: longGroupN?me47
X-Knox-Actor-Groups-72: longGroupN?me70
X-Knox-Actor-Groups-73: longGroupN?me73
X-Knox-Actor-Groups-74: longGroupN?me74
X-Knox-Actor-Groups-75: longGroupN?me71
X-Knox-Actor-Groups-76: longGroupN?me72
X-Knox-Actor-Groups-77: longGroupN?me77
X-Knox-Actor-Groups-78: longGroupN?me78
X-Knox-Actor-Groups-79: longGroupN?me75
X-Knox-Actor-Groups-80: longGroupN?me76
X-Knox-Actor-Groups-81: longGroupN?me79
X-Knox-Actor-Groups-82: longGroupN?me9
X-Knox-Actor-Groups-83: longGroupN?me8
X-Knox-Actor-Groups-84: longGroupN?me7
X-Knox-Actor-Groups-85: longGroupN?me6
X-Knox-Actor-Groups-86: longGroupN?me5
X-Knox-Actor-Groups-87: longGroupN?me4
X-Knox-Actor-Groups-88: longGroupN?me3
X-Knox-Actor-Groups-89: longGroupN?me2
X-Knox-Actor-Groups-90: longGroupN?me1
X-Knox-Actor-Groups-91: longGroupN?me62
X-Knox-Actor-Groups-92: longGroupN?me63
X-Knox-Actor-Groups-93: longGroupN?me60
X-Knox-Actor-Groups-94: longGroupN?me61
X-Knox-Actor-Groups-95: longGroupN?me66
X-Knox-Actor-Groups-96: longGroupN?me67
X-Knox-Actor-Groups-97: longGroupN?me64
X-Knox-Actor-Groups-98: longGroupN?me65
X-Knox-Actor-Groups-99: longGroupN?me68
X-Knox-Actor-Groups-100: longGroupN?me69
Content-Length: 0
```
Issue Time Tracking
-------------------
Worklog Id: (was: 988192)
Time Spent: 1h (was: 50m)
> Group header value should be based on data size and not number
> --------------------------------------------------------------
>
> Key: KNOX-3035
> URL: https://issues.apache.org/jira/browse/KNOX-3035
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Reporter: Sandeep More
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 3.0.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> KNOX-2974 and KNOX-3023 support adding group headers to requests flowing to
> downstream endpoints. Currently the groups headers is based on number of
> groups (1000 default). A lot of webservers and loadbalancers support header
> sizes between 4KB - 8KB which be an issue when header sizes are large.
> This JIRA is to update this logic to limit groups in one header to configured
> size in KBs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)