mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Support for multipart formdata in RequestMessage #580
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 @chrischu on GitHub (Mar 4, 2024).
Originally assigned to: @StefH on GitHub.
Is your feature request related to a problem? Please describe.
As far as I can tell the
RequestMessageonly has good support for URL-encoded form data.Describe the solution you'd like
It would be cool if there was support for multipart form data as well (e.g. like
HttpRequest.Formfrom .NET Core).Describe alternatives you've considered
An alternative would be to implement the form parsing myself, which is something I'll do in the short term, but long term I would prefer if WireMock.Net had support for this pretty common content type (afaik it is still the default solution when doing large file uploads with accompanying other data).
@StefH commented on GitHub (Mar 4, 2024):
@chrischu
I think you can use https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-MimePartMatcher for that.
@chrischu commented on GitHub (Mar 4, 2024):
Interesting, but can I use these matchers to assert the requests that were sent?
e.g.
server.LogEntries.Select(e => e.RequestMessage).HasMultipartFormData(...)or something like that?@StefH commented on GitHub (Mar 4, 2024):
The request message contains a property
object? BodyAsMimeMessagewhich isMimeMessage(from MimeKitLite) which you can use to verify.@chrischu commented on GitHub (Mar 4, 2024):
Ok I was not aware that a MimeMessage is the same as multipart form data 😮
@StefH commented on GitHub (Mar 6, 2024):
@chrischu Does this answer your question?
@chrischu commented on GitHub (Mar 7, 2024):
Kinda, it gives me a possible workaround, but I still think that requiring users to
is not really a great user experience.
@StefH commented on GitHub (Mar 7, 2024):
I understand your points.
object?is that the dependency on MimeKitLite is not for all frameworks. In the future I'll split the packages and projects (https://github.com/WireMock-Net/WireMock.Net/issues/1071)@chrischu commented on GitHub (Mar 7, 2024):
Especially the 2nd point would hint at the fact, that probably using MimeKit to parse multipart form data is not the right choice? ASP.NET Core should have stuff to parse form data (as it can parse form data by itself). Maybe it would be better to use that instead of forcing a dependency on MimeKit?