From da4674f0b9b329c716a51f4fd0f505844c9ca0fd Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 18 Nov 2018 16:11:43 -0800 Subject: [PATCH] Switch to using request.Context() License: MIT Signed-off-by: Jeromy --- core/corehttp/gateway_handler.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 01274cb6e31..2f4455db556 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -64,23 +64,11 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { chunker.DefaultSplitter(r)) } -// TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - 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 + ctx, cancel := context.WithTimeout(r.Context(), time.Hour) defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - clientGone := cn.CloseNotify() - go func() { - select { - case <-clientGone: - case <-ctx.Done(): - } - cancel() - }() - } - defer func() { if r := recover(); r != nil { log.Error("A panic occurred in the gateway handler!")