mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
StatusCode is defined as integer (string is not possible) #226
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 @hsnsalhi on GitHub (Nov 29, 2019).
Hello,
I want to extract the status code from url but the mapping json is skipped because StatusCode can't be as string.
This is an example of what I want to do:
@StefH commented on GitHub (Nov 29, 2019):
According to HTTP specification, I think it's only allowed to use a number between 100 and 599 as status code.
@hsnsalhi commented on GitHub (Nov 29, 2019):
Yes, in fact my use case respects this spec (the example was just to show what I need)
But the problem is in the string to number conversion. the Response object does not accept StatusCode to be string, neither the method WithStatusCode in C# code.
@StefH commented on GitHub (Nov 29, 2019):
Correct. The reason that you cannot use a string because it should always be an integer. So what issue do you have with this?
@hsnsalhi commented on GitHub (Nov 29, 2019):
In this case, is there a way to extract the status code from the url ?
example:
I send http://localhost/test/statuscode401
And the response should be with status code 401
@StefH commented on GitHub (Nov 29, 2019):
If you send something like
http://localhost/test/statuscode/401, then you can get the 401 using:request.PathSegments.[2].However, at this moment, you cannot set this to the StatusCode because only integer is allowed.
This could be implemented with a new cast extension on Handlebars. I can investigate this.
Also allowing a the code to be converted from string to integer could be an option.
(BTW I need to check if the StatusCode is actually processed by Handlebars...)
@StefH commented on GitHub (Nov 29, 2019):
BTW just posting a new mapping to the __admin is possible with a string as StatusCode:
@hsnsalhi commented on GitHub (Nov 29, 2019):
Actually it's the workaround I'm working with.
I create a mapping for every possible status code returned by the mocked API
Thank you for your help
@StefH commented on GitHub (Nov 30, 2019):
@hsnsalhi
Can you try
WireMock.Net.1.0.37-ci-12253.nupkgfrom MyGet ? (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)@StefH commented on GitHub (Dec 3, 2019):
@hsnsalhi Can you try if this version solves your issue?
@StefH commented on GitHub (Dec 5, 2019):
@hsnsalhi Can you please test if that version solves your problem?
@StefH commented on GitHub (Dec 10, 2019):
@hsnsalhi Can you please test if that version solves your problem?
@StefH commented on GitHub (Dec 17, 2019):
@hsnsalhi Can you please test?