Просмотр исходного кода

Cancel request in streaming handler only if it exists

DarthSim 5 месяцев назад
Родитель
Сommit
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))
 	}