mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Fail after half of the body has been sent #277
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @drauch on GitHub (Jun 23, 2020).
Hi!
We want to simulate in a test that sending the response fails after half of the body has already been sent to the client. The best we could come up with has been:
_server.Given(Request.Create().UsingGet())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK).WithBody(rm => throw new Exception()));
However, this already returns InternalServerError instead of OK to the client. That's not what we want.
How to properly return OK and then fail after a few bytes of the body have been sent?
Best regards,
D.R.
@StefH commented on GitHub (Jun 23, 2020):
It's not really possible yet to read half of data and return an error.
What you can do is use Faults?
https://github.com/WireMock-Net/WireMock.Net/wiki/Faults
@drauch commented on GitHub (Jun 23, 2020):
Thanks, that should hopefully work for me. Will report back if I run into troubles.