mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
docs: clarify reverse proxy compatibility behavior
Document BufferPool usage and explain why trailer fallback and disconnect compatibility logic intentionally mirror the standard library reverse proxy. Add a regression test covering unannounced trailer forwarding so that proxy trailer behavior stays aligned with Go's semantics.
This commit is contained in:
parent
764a764720
commit
e4ca20e848
3 changed files with 80 additions and 0 deletions
|
|
@ -359,6 +359,10 @@ func (p *reverseProxyHandler) ServeHTTP(c *Context) {
|
|||
c.Writer.Flush()
|
||||
}
|
||||
|
||||
// Keep the stdlib-compatible fallback here.
|
||||
// If the backend only exposes additional trailer keys after the body has been
|
||||
// fully read, the trailer map can grow and those values must be written using
|
||||
// the TrailerPrefix form instead of the pre-announced bare header keys.
|
||||
if len(res.Trailer) == announcedTrailers {
|
||||
reverseProxyCopyHeader(c.Writer.Header(), res.Trailer)
|
||||
return
|
||||
|
|
@ -378,6 +382,11 @@ func (p *reverseProxyHandler) requestContext(c *Context) (context.Context, conte
|
|||
return ctx, func() {}
|
||||
}
|
||||
|
||||
// Follow the same compatibility path as net/http/httputil.ReverseProxy:
|
||||
// request contexts are normally cancelable, but middleware can still replace
|
||||
// c.Request with one backed by context.Background/TODO or another context with
|
||||
// a nil Done channel. In that case CloseNotifier still provides disconnect
|
||||
// propagation for the upstream round trip.
|
||||
rawWriter := reverseProxyBaseResponseWriter(c.Writer)
|
||||
cn, ok := rawWriter.(http.CloseNotifier)
|
||||
if !ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue