提交 bf955f35 作者: Jeromy

add closenotify and large timeout to gateway

License: MIT
Signed-off-by: 's avatarJeromy <jeromyj@gmail.com>
上级 18099abb
......@@ -95,9 +95,20 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithCancel(i.node.Context())
ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour)
// the hour is a hard fallback, we don't expect it to happen, but just in case
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func() {
select {
case <-cn.CloseNotify():
case <-ctx.Done():
}
cancel()
}()
}
urlPath := r.URL.Path
// If the gateway is behind a reverse proxy and mounted at a sub-path,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论