Cache replaceAll regex when normalizing headers

pull/384/head
Andrew Gaul 2021-11-01 18:59:42 +09:00
rodzic cb3845c1ab
commit db2cc2a0ff
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.crypto.Mac;
@ -77,6 +78,7 @@ final class AwsSignature {
"versions",
"website"
);
private static final Pattern REPEATING_WHITESPACE = Pattern.compile("\\s+");
private AwsSignature() { }
@ -237,7 +239,7 @@ final class AwsSignature {
}
value = value.trim();
if (!value.startsWith("\"")) {
value = value.replaceAll("\\s+", " ");
value = REPEATING_WHITESPACE.matcher(value).replaceAll(" ");
}
headersWithValues.append(value);
}