浏览代码

Cancel request in streaming handler only if it exists

DarthSim 1 月之前
父节点
当前提交
49791b03a2
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      handlers/stream/handler.go

+ 3 - 1
handlers/stream/handler.go

@@ -99,7 +99,9 @@ func (s *request) execute(ctx context.Context) error {
 
 	// Build the request to fetch the image
 	r, err := s.handler.fetcher.BuildRequest(ctx, s.imageURL, requestHeaders, cookieJar)
-	defer r.Cancel()
+	if r != nil {
+		defer r.Cancel()
+	}
 	if err != nil {
 		return ierrors.Wrap(err, 0, ierrors.WithCategory(categoryStreaming))
 	}