Преглед на файлове

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
 	// Build the request to fetch the image
 	r, err := s.handler.fetcher.BuildRequest(ctx, s.imageURL, requestHeaders, cookieJar)
 	r, err := s.handler.fetcher.BuildRequest(ctx, s.imageURL, requestHeaders, cookieJar)
-	defer r.Cancel()
+	if r != nil {
+		defer r.Cancel()
+	}
 	if err != nil {
 	if err != nil {
 		return ierrors.Wrap(err, 0, ierrors.WithCategory(categoryStreaming))
 		return ierrors.Wrap(err, 0, ierrors.WithCategory(categoryStreaming))
 	}
 	}