Skip to content
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

Support for multipart formdata in RequestMessage #1076

Closed
chrischu opened this issue Mar 4, 2024 · 8 comments
Closed

Support for multipart formdata in RequestMessage #1076

chrischu opened this issue Mar 4, 2024 · 8 comments
Assignees
Labels

Comments

@chrischu
Copy link

chrischu commented Mar 4, 2024

Is your feature request related to a problem? Please describe.
As far as I can tell the RequestMessage only 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.Form from .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
Copy link
Collaborator

StefH commented Mar 4, 2024

@chrischu
Copy link
Author

chrischu commented 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 StefH self-assigned this Mar 4, 2024
@StefH
Copy link
Collaborator

StefH commented Mar 4, 2024

The request message contains a property object? BodyAsMimeMessage which is MimeMessage (from MimeKitLite) which you can use to verify.

@chrischu
Copy link
Author

chrischu commented Mar 4, 2024

Ok I was not aware that a MimeMessage is the same as multipart form data 😮

@StefH StefH added question and removed feature labels Mar 6, 2024
@StefH
Copy link
Collaborator

StefH commented Mar 6, 2024

@chrischu Does this answer your question?

@chrischu
Copy link
Author

chrischu commented Mar 7, 2024

Kinda, it gives me a possible workaround, but I still think that requiring users to

  • know that MimeMessage can be used to look at multipart form data
  • manually cast the object? to MimeMessage

is not really a great user experience.

@StefH
Copy link
Collaborator

StefH commented Mar 7, 2024

I understand your points.

  1. Correct, this should be added in more detail in the wiki.
  2. The main reason that it's an object? is that the dependency on MimeKitLite is not for all frameworks. In the future I'll split the packages and projects (Split WireMock into multiple nuget packages depending on features #1071)

@chrischu
Copy link
Author

chrischu commented 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?

@StefH StefH closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants