Reject non-successful (2xx) dispatch responses
If a subscriber or reply request returns a non-2xx status code, the
message dispatcher should treat that response as an error. This allows
the bus to Nack delivery of the message for the subscribtion so that it
can be retired, assuming the bus is durable.
@@ -94,6 +94,10 @@ func (d *MessageDispatcher) executeRequest(url *url.URL, message *Message) (*Mes
return nil, err
}
if res != nil {
+ if res.StatusCode < 200 || res.StatusCode >= 300 {
+ // reject non-successful (2xx) responses
+ return nil, fmt.Errorf("unexpected HTTP response, expected 2xx, got %d", res.StatusCode)
+ }
headers := d.fromHTTPHeaders(res.Header)
// TODO: add configurable whitelisting of propagated headers/prefixes (configmap?)
if correlationID, ok := message.Headers[correlationIDHeaderName]; ok {
