WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.39k stars 207 forks source link

Using request multipart in response template #968

Closed rmeshksar closed 1 year ago

rmeshksar commented 1 year ago

Hi, The content-type of the request is multipart/form-data; boundary=4f5cb47fa8f04c7f91424474f070f497+1110027

Each section of multipart is an XML like this:

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N1"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N2"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N3"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027--

In the response template I would like to use XPath to get some information of specific section.

Is it possible?

StefH commented 1 year ago

Currently there is no special logic to parse a multipart and extract the parts. I'll need to think on this how to could be added and how this could be used.

StefH commented 1 year ago

@rmeshksar I'm building support for multipart request matching using MimeKitLite, and I think I can also use this in the templating...

StefH commented 1 year ago

@rmeshksar

You can use preview version 1.5.32-ci-17678 where you can access request.BodyAsMimeMessage which is a MimeMessage from MimeKitLite.

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

StefH commented 1 year ago

@rmeshksar Did you have time to test this preview version?

StefH commented 1 year ago

@rmeshksar Did you have time to test this preview version?

It would really help if you can try this version before I merge to this main and create a new official version.

StefH commented 1 year ago

https://github.com/WireMock-Net/WireMock.Net/pull/981

eetawil commented 7 months ago

Hi @StefH, would this PR solve my problem here: https://stackoverflow.com/questions/77989392/wiremock-net-c-how-to-get-a-pdf-from-a-request-body-form-data

Also is part of the latest nuget package 1.5.47?