fix: use root locale when looking up a response header by name in RouteTest - #1223
Merged
pjfanning merged 1 commit intoAug 24, 2026
Merged
Conversation
…teTest Motivation: `RouteTest#header(name: String)` lowercased the given header name with the JVM default locale before comparing it to `HttpHeader#lowercaseName`, which is built with `toRootLowerCase`. Under a Turkish locale `"If-Match".toLowerCase` yields a dotless i, so the lookup silently returned `None` for any header name containing a capital `I`. The javadsl equivalent (`TestRouteResult`) already uses `toRootLowerCase`. Modification: Use `pekko.util.Helpers.toRootLowerCase` in `RouteTest#header(name)`. Result: Header lookup by name in the Scala testkit is locale independent and matches the javadsl behaviour. Tests: - sbt "http-testkit / Test / testOnly org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTestSpec" - passes with the fix; the new test fails without it - scalafmt --mode diff-ref=origin/main - clean - sbt +mimaReportBinaryIssues - not run; method body change only, no API or binary shape change References: None - found while auditing the code base for locale sensitive lowercasing
Philippus
approved these changes
Aug 24, 2026
pjfanning
added a commit
to pjfanning/incubator-pekko-http
that referenced
this pull request
Aug 24, 2026
…teTest (apache#1223) Motivation: `RouteTest#header(name: String)` lowercased the given header name with the JVM default locale before comparing it to `HttpHeader#lowercaseName`, which is built with `toRootLowerCase`. Under a Turkish locale `"If-Match".toLowerCase` yields a dotless i, so the lookup silently returned `None` for any header name containing a capital `I`. The javadsl equivalent (`TestRouteResult`) already uses `toRootLowerCase`. Modification: Use `pekko.util.Helpers.toRootLowerCase` in `RouteTest#header(name)`. Result: Header lookup by name in the Scala testkit is locale independent and matches the javadsl behaviour. Tests: - sbt "http-testkit / Test / testOnly org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTestSpec" - passes with the fix; the new test fails without it - scalafmt --mode diff-ref=origin/main - clean - sbt +mimaReportBinaryIssues - not run; method body change only, no API or binary shape change References: None - found while auditing the code base for locale sensitive lowercasing (cherry picked from commit 08e174c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
RouteTest#header(name: String)in the Scala testkit lowercased the supplied header name using the JVM default locale:HttpHeader#lowercaseNameis built withtoRootLowerCase, so under a Turkish default locale the two disagree:"If-Match".toLowerCaseisıf-match(dotless i) whilelowercaseNameisif-match. Any header name containing a capitalIthen silently resolves toNone.The rest of the code base already guards against this (
Helpers.toRootLowerCase,CharUtils.toLowerCasefor the ASCII-only paths, andHttpCharsetshas a regression test inTurkishISpec). The javadsl equivalent,javadsl/testkit/TestRouteResult, already usestoRootLowerCase— only the scaladsl side was missed.Modification
Use
pekko.util.Helpers.toRootLowerCaseinRouteTest#header(name).Result
Header lookup by name in the Scala testkit is locale independent and consistent with both
HttpHeader#lowercaseNameand the javadsl testkit.Tests
ScalatestRouteTestSpecthat sets the default locale totr-TR(restoring it in afinally) and looks up anIf-Matchheader by name. It fails withNone was not equal to Some(If-Match: "xyzzy")before the fix and passes after it.sbt "http-testkit / Test / testOnly org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTestSpec"- 12 tests passed (JDK 21).scalafmt --mode diff-ref=origin/main- clean.sbt +mimaReportBinaryIssues- not run; this is a method body change with no public API or binary shape change.References
None - found while auditing the code base for locale sensitive lowercasing