AlexStocks commented on issue #3266: URL: https://github.com/apache/dubbo-go/issues/3266#issuecomment-4102228719
## Code Review 分析了 `protocol/triple/client.go` 和 `protocol/triple/triple_protocol/negotiation.go` 中的 HTTP/3 协商和回退实现,发现以下问题: --- ### 1. [严重] req.Body 被消耗后无法正确回退到 HTTP/2 `dt.http3Transport.RoundTrip(req)`(client.go:359)可能会消耗 `req.Body` 的数据。当 `req.Body` 是一个 pipe 时,HTTP/3 transport 开始读取后数据被消费,回退到 HTTP/2 时无法重放请求体。 **建议:** 在 HTTP/3 尝试前克隆请求或使用 `req.GetBody`,HTTP/3 失败后重新构建可重放的请求体回退到 HTTP/2。 --- ### 2. [中等] AltSvcInfo.Host 和 Port 从未被使用 `parseAuthority` 解析了 `Host` 和 `Port`(negotiation.go:206-228),但 `RoundTrip` 中只用了 `req.URL.Host`,完全忽略了 Alt-Svc 中指定的不同 endpoint。注释说"If empty, use the same host",但实际没有实现。 --- ### 3. [中等] HTTP/3 失败后没有健康检查/冷却机制 HTTP/3 失败后只对当前请求回退到 HTTP/2,下一个请求仍会立即尝试 HTTP/3。如果 QUIC 路径持续不可达,会不断重试。 **建议:** 记录失败次数,实现冷却机制(如 `cooldownUntil time.Time`),在一段时间内跳过 HTTP/3 尝试。 --- ### 4. [轻微] ma=0 未被正确处理 negotiation.go:192 中 `age > 0` 的判断意味着 `ma=0` 会被忽略。但 RFC 7838 规定 `ma=0` 表示**立即失效**,应该立即过期而不是使用默认的 24 小时。 --- ### 5. [轻微] 缺少 Alt-Svc 撤回处理 `AltSvcCache.Get` 对过期条目返回 nil,但没有显式的 `Remove` 方法来处理已撤回的 alternative service。 -- 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]
