dukeofharen / httplaceholder

A very flexible cross platform HTTP stub application.
MIT License
109 stars 4 forks source link

Check if body is set before writing to response #317

Closed dukeofharen closed 1 year ago

dukeofharen commented 1 year ago

Pull request type

Please check the type of change your PR introduces:

What is the current behavior?

An exception is thrown when using the reverse proxy response writer and the called server returns an HTTP 204. An empty body is written to the response, which is not allowed by .NET, which results in an exception.

What is the new behavior?

At first, a check was done that the returned response is not null before writing the stub response. Since an empty body is not null, the empty body was written and an exception was thrown. Now, we also check whether the body has contents before writing it to the response.

Does this introduce a breaking change?