mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
fix: tighten reverse proxy safety handling
Avoid HTTP error writes after hijacking upgraded connections, document ModifyResponse constraints for 101 responses, and normalize forwarded query strings consistently to reduce parsing ambiguity across proxy chains.
This commit is contained in:
parent
1946216c0e
commit
6d89b8674f
3 changed files with 13 additions and 5 deletions
|
|
@ -472,6 +472,10 @@ func (p *reverseProxyHandler) handleError(c *Context, err error) {
|
|||
return
|
||||
}
|
||||
c.AddError(err)
|
||||
if c.Writer.IsHijacked() {
|
||||
p.logf(c, "reverse proxy error after hijack: %v", err)
|
||||
return
|
||||
}
|
||||
if p.config.ErrorHandler != nil {
|
||||
p.config.ErrorHandler(c.Writer, c.Request, err)
|
||||
if c.Writer.Written() || c.Writer.IsHijacked() {
|
||||
|
|
@ -906,10 +910,7 @@ func cleanReverseProxyQueryParams(rawQuery string) string {
|
|||
if rawQuery == "" {
|
||||
return ""
|
||||
}
|
||||
values, err := url.ParseQuery(rawQuery)
|
||||
if err == nil {
|
||||
return rawQuery
|
||||
}
|
||||
values, _ := url.ParseQuery(rawQuery)
|
||||
return values.Encode()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue