Skip to content

Commit

Permalink
add Prefer: reply always
Browse files Browse the repository at this point in the history
  • Loading branch information
salaboy committed Sep 30, 2021
1 parent f31d9f8 commit adbd44a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/channel/message_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,9 @@ func (d *MessageDispatcherImpl) DispatchMessageWithRetries(ctx context.Context,
// Try to send to destination
messagesToFinish = append(messagesToFinish, message)

// Add Prefer: reply header if a reply destination is provided
// Add `Prefer: reply` header no matter if a reply destination is provided. Discussion: https://github.com/knative/eventing/pull/5764
additionalHeadersForDestination := additionalHeaders.Clone()
if reply != nil {
additionalHeadersForDestination.Add("Prefer", "reply")
}
additionalHeadersForDestination.Add("Prefer", "reply")

ctx, responseMessage, responseAdditionalHeaders, dispatchExecutionInfo, err = d.executeRequest(ctx, destination, message, additionalHeadersForDestination, retriesConfig, transformers...)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/channel/message_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestDispatchMessage(t *testing.T) {
"x-request-id": {"id123"},
"knative-1": {"knative-1-value"},
"knative-2": {"knative-2-value"},
"prefer": {"reply"},
"traceparent": {"ignored-value-header"},
"ce-abc": {`"ce-abc-value"`},
"ce-id": {"ignored-value-header"},
Expand Down Expand Up @@ -133,6 +134,7 @@ func TestDispatchMessage(t *testing.T) {
"x-request-id": {"id123"},
"knative-1": {"knative-1-value"},
"knative-2": {"knative-2-value"},
"prefer": {"reply"},
"traceparent": {"ignored-value-header"},
"ce-abc": {`"ce-abc-value"`},
"ce-id": {"ignored-value-header"},
Expand Down Expand Up @@ -373,6 +375,7 @@ func TestDispatchMessage(t *testing.T) {
"x-request-id": {"id123"},
"knative-1": {"knative-1-value"},
"knative-2": {"knative-2-value"},
"prefer": {"reply"},
"traceparent": {"ignored-value-header"},
"ce-abc": {`"ce-abc-value"`},
"ce-id": {"ignored-value-header"},
Expand Down Expand Up @@ -440,6 +443,7 @@ func TestDispatchMessage(t *testing.T) {
"x-request-id": {"id123"},
"knative-1": {"knative-1-value"},
"knative-2": {"knative-2-value"},
"prefer": {"reply"},
"traceparent": {"ignored-value-header"},
"ce-abc": {`"ce-abc-value"`},
"ce-id": {"ignored-value-header"},
Expand Down Expand Up @@ -649,6 +653,7 @@ func TestDispatchMessage(t *testing.T) {
"x-request-id": {"id123"},
"knative-1": {"knative-1-value"},
"knative-2": {"knative-2-value"},
"prefer": {"reply"},
"traceparent": {"ignored-value-header"},
"ce-abc": {`"ce-abc-value"`},
"ce-id": {"ignored-value-header"},
Expand Down

0 comments on commit adbd44a

Please sign in to comment.