in runtime/protocol/http/common/src/aws/smithy/kotlin/runtime/http/util/HeaderLists.kt [19:47]
fun splitHttpDateHeaderListValues(value: String): List<String> {
val n = value.count { it == ',' }
if (n <= 1) {
return listOf(value)
} else if (n % 2 == 0) {
throw ClientException("invalid timestamp HttpDate header comma separations: `$value`")
}
var cnt = 0
val splits = mutableListOf<String>()
var startIdx = 0
for (i in value.indices) {
if (value[i] == ',') cnt++
// split on every other ','
if (cnt > 1) {
splits.add(value.substring(startIdx, i).trim())
startIdx = i + 1
cnt = 0
}
}
if (startIdx < value.length) {
splits.add(value.substring(startIdx).trim())
}
return splits
}