mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Issue : creating response using .WithBody(Func<RequestMessage, string>...) and .WithStatusCode #141
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 @rickm-pra on GitHub (Sep 4, 2018).
Originally assigned to: @StefH on GitHub.
If I set up a response using both .WithBody and .WithStatusCode, it always returns a status code of 200. For example:
will return the error message but with a 200 status.
It looks like the root cause is that the response callback is creating a new response instead of using the one that was configured.
@StefH commented on GitHub (Sep 4, 2018):
Do you have multiple mappings defined, or just this one?
In case you have multiple, it could be that another mapping does match better than this one.
@rickm-pra commented on GitHub (Sep 4, 2018):
I tried it both ways. The number of mappings has no effect.
@rickm-pra commented on GitHub (Sep 4, 2018):
My crude fix was to change ProvideResponseAsync in Response.cs:
I doubt very much this is the right fix, but it does set the code properly.
@StefH commented on GitHub (Sep 4, 2018):
This is indeed a bug. Thanks for reporting. I'll investigate and fix this.
@rickm-pra commented on GitHub (Sep 4, 2018):
Thanks!
@StefH commented on GitHub (Sep 4, 2018):
Issue is solved, I created a PR , take a look here:
https://github.com/WireMock-Net/WireMock.Net/pull/199
You can review but probably not approve this PR?
@rickm-pra commented on GitHub (Sep 4, 2018):
I can review, but it's not a binding approve. Looks good though!