Skip to content

Commit

Permalink
[release-1.13] Fix mtbroker-filter to proxy response headers (#7633)
Browse files Browse the repository at this point in the history
* Fix mtbroker-filter to proxy response headers

* Switch to utils.PassThroughHeaders

---------

Co-authored-by: Christoph Stäbler <cstabler@redhat.com>
  • Loading branch information
knative-prow-robot and creydr committed Jan 29, 2024
1 parent fd95228 commit 2e6742c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/broker/filter/filter_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ func (h *Handler) writeResponse(ctx context.Context, writer http.ResponseWriter,
writer.WriteHeader(http.StatusBadGateway)
return http.StatusBadGateway, errors.New("received a non-empty response not recognized as CloudEvent. The response MUST be either empty or a valid CloudEvent")
}
writeHeaders(dispatchInfo.ResponseHeader, writer) // Proxy original Response Headers for downstream use

writeHeaders(utils.PassThroughHeaders(dispatchInfo.ResponseHeader), writer) // Proxy original Response Headers for downstream use
h.logger.Debug("Response doesn't contain a CloudEvent, replying with an empty response", zap.Any("target", target))
writer.WriteHeader(dispatchInfo.ResponseCode)
return dispatchInfo.ResponseCode, nil
Expand All @@ -467,7 +468,7 @@ func (h *Handler) writeResponse(ctx context.Context, writer http.ResponseWriter,
defer eventResponse.Finish(nil)

// Proxy the original Response Headers for downstream use
writeHeaders(dispatchInfo.ResponseHeader, writer)
writeHeaders(utils.PassThroughHeaders(dispatchInfo.ResponseHeader), writer)

if err := cehttp.WriteResponseWriter(ctx, eventResponse, dispatchInfo.ResponseCode, writer); err != nil {
return http.StatusInternalServerError, fmt.Errorf("failed to write response event: %w", err)
Expand Down

0 comments on commit 2e6742c

Please sign in to comment.