-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content-Type multipart/form-data is not serialized in proxy and recording mode #263
Comments
If possible, can you provide the full body (captured using fiddler for example)? |
Body content obtained with fiddler:
|
I checked, and this is actually I left out Bytes / Multipart because I'm not sure which matcher to use. |
I don't know what to do with this answer 😢 It seems to me that the content in sent in text so it should be possible to do some checks. I don't know if we could not have a "No check" matcher so that we could have the value received serialized in the mapping file but ignored in the matching process. That way the developer could really see what have been sent. Thanks for the answer. |
Sorry for my short answer. What I just meant to say is that up until your question, I did not really think it would be usefull / possible to save the body in case of Bytes or Multipart. I think using the |
Using the ExactObjectMatcher would return the body in the mapping as: Example: "Body": {
"Matcher": {
"Name": "ExactObjectMatcher",
"Pattern": "LS0xNjU4YTNjMi05NzhkLTQyNWUtOTZiMy04YzE1MTcxZDc1NWQNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD11dGYtOA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPXRlc3Q7IGZpbGVuYW1lPXRlc3QudHh0OyBmaWxlbmFtZSo9dXRmLTgnJ3Rlc3QudHh0DQoNCmRhdGENCi0tMTY1OGEzYzItOTc4ZC00MjVlLTk2YjMtOGMxNTE3MWQ3NTVkLS0NCg=="
}
} Would this be ok? |
Linked to PR - #264 |
I can also build some logic to check if the data is a valid ASCII string, in that case I can change the detection from MultiPart logic and the code will automatically used the current string matchers... In this case, the mapping would look like: "Body": {
"Matcher": {
"Name": "ExactMatcher",
"Pattern": "--cea0a92a-94b2-4c5c-b3d9-da77d4220113\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=test; filename=test.txt; filename*=utf-8''test.txt\r\n\r\ndata\r\n--cea0a92a-94b2-4c5c-b3d9-da77d4220113--\r\n"
}
} |
I'm really impress and appreciate this very quick PR 👍
I don't think it will be very useful due to the multiparts boundaries that are by default auto generated and, so, varies and consequently, the ExactObjectMatcher will match nothing :(
Something like that will indeed be much more valuable and will let the developer check for part of the string (without the boundaries, for example). |
Would the mapping in my proposal work for you? "Body": {
"Matcher": {
"Name": "ExactMatcher",
"Pattern": "--cea0a92a-94b2-4c5c-b3d9-da77d4220113\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=test; filename=test.txt; filename*=utf-8''test.txt\r\n\r\ndata\r\n--cea0a92a-94b2-4c5c-b3d9-da77d4220113--\r\n"
}
} |
I'm not very used to mapping file but will I be able to modified it to look like below and that will still work? "Body": {
"Matcher": {
"Name": "WildcardMatcher",
"Pattern": "--*\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Disposition: form-data; name=test; filename=test.txt; filename*=utf-8''test.txt\r\n\r\ndata\r\n--*--\r\n"
}
} If yes, 👍 |
You can indeed change the generated mapping to use the |
@pmiossec |
I'll try to do that. Thanks a lot again (especially for your spontaneity!)
…On Tue, 2 Apr 2019 at 15:02, Stef Heyenrath ***@***.***> wrote:
@pmiossec <https://github.com/pmiossec>
If you like, you can use this preview NuGet which includes this code.
https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net/1.0.12-ci-11179
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#263 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAcFpBZZj_p8Q2lx5bm2aEIsBZ-hscRJks5vc1T_gaJpZM4cVYcI>
.
|
@pmiossec Does that NuGet work correct for you? |
@StefH I have tested it and it is working as expected. Thank you very much! |
Today a new official NuGet will be released. |
In the last version of
WireMock.Net.StandAlone
( Version="1.0.8"), when doing a Content-Type multipart/form-data POST request, the mapping generated doesn't contain the Matcher for the body (so that don't made it a valid mapping).Note: I forward to another Wiremock instance and see the content of the body, so the content seems to be forwarded.
I get the generated mapping (Notice the empty "Body" key) :
I have the same behavior when doing the request through Postman or C# code...
If you want to test, you could reproduce with this code.
The text was updated successfully, but these errors were encountered: