Skip to content

Commit

Permalink
fix(gw): panic in handler_car.go (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Apr 3, 2023
2 parents 95126f6 + 67153ec commit 085ed9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gateway/handler_car.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ func (i *handler) serveCAR(ctx context.Context, w http.ResponseWriter, r *http.R

_, copyErr := io.Copy(w, carFile)
carErr := <-errCh
if copyErr != nil || carErr != nil {
streamErr := multierr.Combine(carErr, copyErr)
if streamErr != nil {
// We return error as a trailer, however it is not something browsers can access
// (https://github.com/mdn/browser-compat-data/issues/14703)
// Due to this, we suggest client always verify that
// the received CAR stream response is matching requested DAG selector
w.Header().Set("X-Stream-Error", multierr.Combine(err, copyErr).Error())
w.Header().Set("X-Stream-Error", streamErr.Error())
return false
}

Expand Down

0 comments on commit 085ed9d

Please sign in to comment.