Adding error to protocol result if not 200 status code#686
Adding error to protocol result if not 200 status code#686n3wscott merged 3 commits intocloudevents:mainfrom
Conversation
|
@n3wscott could you take a look at this one? |
v2/protocol/http/protocol_retry.go
Outdated
| result = protocol.ResultACK | ||
| } else { | ||
| result = protocol.ResultNACK | ||
| respbody, err := ioutil.ReadAll(resp.Body) |
There was a problem hiding this comment.
Reading the body here will cause line 54 to error I think, because the body will have already been read.
The body of the response is already returned within the message, this change should not be required.
There was a problem hiding this comment.
The change was made because the message is dropped later on here: https://github.com/cloudevents/sdk-go/blob/main/v2/protocol/http/protocol.go#L142
There was a problem hiding this comment.
How about we read and wrap the returned message from Request in Send and return it if err is not nil on L142? So fix the problem one bump up, rather than in protocol_retry. Seems like protocol_retry is doing the right thing, we just need to not drop the body if there is an error in Send.
Signed-off-by: Daniel Grist <dgrist@ibm.com>
fd8b763 to
be22d6a
Compare
Signed-off-by: Daniel Grist <dgrist@ibm.com>
be22d6a to
6c2dbab
Compare
Signed-off-by: Daniel Grist <dgrist@ibm.com>
Adding the error message to the protocol result so it can be retrieved when there are non 200 status codes.
Signed-off-by: Daniel Grist dgrist@ibm.com