flush921 opened a new pull request, #16600: URL: https://github.com/apache/dubbo/pull/16600
## What is the purpose of the change? Fix two bugs in HTTP request locale negotiation in `dubbo-remoting-http12`: 1. **Wrong request header in `DefaultHttpRequest.locales()`**: `DefaultHttpRequest.locales()` read `HttpHeaderNames.CONTENT_LANGUAGE` instead of `Accept-Language`. Added `HttpHeaderNames.ACCEPT_LANGUAGE` (wrapping Netty's `HttpHeaderNames.ACCEPT_LANGUAGE`) and updated `DefaultHttpRequest.locales()` to read it. 2. **Broken q-value parsing in `HttpUtils.parseAcceptLanguage()`**: `HttpUtils.parseAcceptLanguage()` previously called `Float.parseFloat(pair[1])` directly on the parameter token (e.g. `"q=0.5"`), throwing `NumberFormatException` on any RFC 9110 `Accept-Language` header containing quality weights. Reused `HttpUtils.parseQuality(item, index)` (matching `HttpUtils.parseAccept()`), skipped empty language segments before `;`, and updated `HttpUtils.parseQuality()` to also stop at `;` (when additional parameters follow `q=...`) and trim trailing whitespace. ### Verification - Added unit tests in `HttpUtilsTest` (`testParseQuality`, `testParseAcceptLanguage`) and `DefaultHttpRequestTest` (`parsesLocalesFromAcceptLanguageHeader`). - Verified the new tests fail prior to the fix (`NumberFormatException: For input string: "q=0.5"` and `expected: <[zh_CN, en]> but was: <[de_DE]>`). - Verified `./mvnw test checkstyle:check spotless:check -pl dubbo-remoting/dubbo-remoting-http12` passes (51 tests, 0 failures, 0 errors). ## Checklist - [ ] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project. - [x] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- 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]
