Skip to content

Commit

Permalink
fix: handle _redirects for If-None-Match headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann authored and hacdias committed Jul 24, 2023
1 parent f6b448b commit 267b14f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,19 @@ func (i *handler) handleIfNoneMatch(w http.ResponseWriter, r *http.Request, rq *
if ifNoneMatch := r.Header.Get("If-None-Match"); ifNoneMatch != "" {
pathMetadata, err := i.backend.ResolvePath(r.Context(), rq.immutablePath)
if err != nil {
err = fmt.Errorf("failed to resolve %s: %w", debugStr(rq.contentPath.String()), err)
i.webError(w, r, err, http.StatusInternalServerError)
return true
var forwardedPath ImmutablePath
var continueProcessing bool
if isWebRequest(rq.responseFormat) {
forwardedPath, continueProcessing = i.handleWebRequestErrors(w, r, rq.mostlyResolvedPath(), rq.immutablePath, rq.contentPath, err, rq.logger)
if continueProcessing {
pathMetadata, err = i.backend.ResolvePath(r.Context(), forwardedPath)
}

Check warning on line 712 in gateway/handler.go

View check run for this annotation

Codecov / codecov/patch

gateway/handler.go#L706-L712

Added lines #L706 - L712 were not covered by tests
}
if !continueProcessing || err != nil {
err = fmt.Errorf("failed to resolve %s: %w", debugStr(rq.contentPath.String()), err)
i.webError(w, r, err, http.StatusInternalServerError)
return true
}

Check warning on line 718 in gateway/handler.go

View check run for this annotation

Codecov / codecov/patch

gateway/handler.go#L714-L718

Added lines #L714 - L718 were not covered by tests
}

pathCid := pathMetadata.LastSegment.Cid()
Expand Down

0 comments on commit 267b14f

Please sign in to comment.