pjfanning opened a new pull request, #1223:
URL: https://github.com/apache/pekko-http/pull/1223

   ### Motivation
   `RouteTest#header(name: String)` in the Scala testkit lowercased the 
supplied header name using the JVM default locale:
   
   ```scala
   def header(name: String): Option[HttpHeader] = 
rawResponse.headers.find(_.is(name.toLowerCase))
   ```
   
   `HttpHeader#lowercaseName` is built with `toRootLowerCase`, so under a 
Turkish default locale the two disagree: `"If-Match".toLowerCase` is `ıf-match` 
(dotless i) while `lowercaseName` is `if-match`. Any header name containing a 
capital `I` then silently resolves to `None`.
   
   The rest of the code base already guards against this 
(`Helpers.toRootLowerCase`, `CharUtils.toLowerCase` for the ASCII-only paths, 
and `HttpCharsets` has a regression test in `TurkishISpec`). The javadsl 
equivalent, `javadsl/testkit/TestRouteResult`, already uses `toRootLowerCase` — 
only the scaladsl side was missed.
   
   ### Modification
   Use `pekko.util.Helpers.toRootLowerCase` in `RouteTest#header(name)`.
   
   ### Result
   Header lookup by name in the Scala testkit is locale independent and 
consistent with both `HttpHeader#lowercaseName` and the javadsl testkit.
   
   ### Tests
   - Added a regression test to `ScalatestRouteTestSpec` that sets the default 
locale to `tr-TR` (restoring it in a `finally`) and looks up an `If-Match` 
header by name. It fails with `None 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


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

To unsubscribe, e-mail: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to