AlexStocks commented on code in PR #1078:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1078#discussion_r4505143774
##########
pkg/filter/http/httpproxy/routerfilter.go:
##########
@@ -135,6 +135,7 @@ func (f *Filter) Decode(hc *contexthttp.HttpContext)
filter.FilterStatus {
Host: endpoint.Address.GetAddress(),
Scheme: f.scheme,
Path: r.URL.Path,
+ RawPath: r.URL.RawPath,
Review Comment:
💭 建议在这里补一句注释,把这个隐含依赖写出来:
```go
// RawPath is only honored by url.URL.EscapedPath when it still decodes to
// Path, so a rewrite done through HttpContext.SetUrl (which only touches
// Path) automatically falls back to re-escaping instead of forwarding a
// stale escaped form.
RawPath: r.URL.RawPath,
```
现在这个语义完全依赖 stdlib(`net/url.EscapedPath` 里 `validEncoded`
的判断),代码里看不到,读的人容易误以为 RawPath 是权威值、或者反过来以为它没用。
另外顺带记录一个与本 PR 无关的观察:`req.Header = r.Header` 之后没有设置 `req.Host`,所以 upstream
收到的是 `endpoint.Address` 作为 Host,也没有
`X-Forwarded-Host`/`X-Forwarded-Proto`。这属于既有行为、不在本次范围,但值得单独开
issue——很多上游的虚拟主机路由/重定向会依赖原始 Host。
--
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]