Content-Type multipart/form-data header not proxied #693

Closed
opened 2025-12-29 15:31:02 +01:00 by adam · 11 comments
Owner

Originally created by @AntoineBriseboisRoy on GitHub (May 15, 2025).

Originally assigned to: @StefH on GitHub.

Describe the bug

I was having some trouble with a proxied call returning 415 status code. I then looked for the headers sent from WireMock service using the postman-echo endpoint like this:

Image

You can clearly see that the multipart/form-data is not pass as header:

Image

However I tried with other headers, like application/json, and this one works.

Expected behavior:

I would expect the headers to be passed using proxy.

I noticed that this issue starts occuring in version 1.6.4 of the nuget package. Before that, all what working great.

Originally created by @AntoineBriseboisRoy on GitHub (May 15, 2025). Originally assigned to: @StefH on GitHub. ### Describe the bug I was having some trouble with a proxied call returning 415 status code. I then looked for the headers sent from WireMock service using the postman-echo endpoint like this: ![Image](https://github.com/user-attachments/assets/40e56ad2-6827-4be6-a018-081eaf89c8af) You can clearly see that the multipart/form-data is not pass as header: ![Image](https://github.com/user-attachments/assets/af033277-6fc2-407e-b4ef-ef68278d6beb) However I tried with other headers, like application/json, and this one works. ### Expected behavior: I would expect the headers to be passed using proxy. ### Other related info I noticed that this issue starts occuring in version 1.6.4 of the nuget package. Before that, all what working great.
adam added the bug label 2025-12-29 15:31:02 +01:00
adam closed this issue 2025-12-29 15:31:02 +01:00
Author
Owner

@StefH commented on GitHub (May 15, 2025):

@AntoineBriseboisRoy
Thanks for this noticing this bug.

Beside this error, the whole body is not proxied...
I'll fix it.

@StefH commented on GitHub (May 15, 2025): @AntoineBriseboisRoy Thanks for this noticing this bug. Beside this error, the whole body is not proxied... I'll fix it.
Author
Owner

@StefH commented on GitHub (May 15, 2025):

https://github.com/wiremock/WireMock.Net/pull/1296

@StefH commented on GitHub (May 15, 2025): https://github.com/wiremock/WireMock.Net/pull/1296
Author
Owner

@StefH commented on GitHub (May 15, 2025):

@AntoineBriseboisRoy
Can you confirm that indeed the body is missing in the echo postman?

@StefH commented on GitHub (May 15, 2025): @AntoineBriseboisRoy Can you confirm that indeed the body is missing in the echo postman?
Author
Owner

@AntoineBriseboisRoy commented on GitHub (May 15, 2025):

I'm sending a body like this one:

Image

And the screenshot I showed you at first doesn't seem to have a returned body. So yeah.

@AntoineBriseboisRoy commented on GitHub (May 15, 2025): I'm sending a body like this one: ![Image](https://github.com/user-attachments/assets/18eb2b87-5e5a-4539-a6d7-5123bbb1364c) And the screenshot I showed you at first doesn't seem to have a returned body. So yeah.
Author
Owner

@AntoineBriseboisRoy commented on GitHub (May 15, 2025):

Thank you for the fix. Can you tell me when the new Nuget will be available?

@AntoineBriseboisRoy commented on GitHub (May 15, 2025): Thank you for the fix. Can you tell me when the new Nuget will be available?
Author
Owner

@StefH commented on GitHub (May 15, 2025):

In 1 hour

@StefH commented on GitHub (May 15, 2025): In 1 hour
Author
Owner

@AntoineBriseboisRoy commented on GitHub (May 16, 2025):

@StefH I hate to say this but the fix is not working:

Image

All the requests I do using multipart/form-data Content-Type while proxy return that, even the postman echo one that was working before. Any idea?

@AntoineBriseboisRoy commented on GitHub (May 16, 2025): @StefH I hate to say this but the fix is not working: ![Image](https://github.com/user-attachments/assets/c7c0c80b-679b-4ed4-91d0-ee98d64cb7ad) All the requests I do using multipart/form-data Content-Type while proxy return that, even the postman echo one that was working before. Any idea?
Author
Owner

@StefH commented on GitHub (May 16, 2025):

I think there is too much business logic in WireMock.Net which tries to understand the header + body.
In your example, you use header Content-Type multipart/form-data but the body is json, and this does not match.

So try sending:

  • header: Content-Type multipart/form-data
  • with a real multipart as body:
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="text"
text default
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain
Content of a txt
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html
<!DOCTYPE html><title>Content of a.html.</title>
-----------------------------9051914041544843365972754266--

can you try this?


But in this case, I think that an exception is thrown, this should be fixed.

@StefH commented on GitHub (May 16, 2025): I think there is too much business logic in WireMock.Net which tries to understand the header + body. In your example, you use header Content-Type multipart/form-data but the body is json, and this does not match. So try sending: - header: `Content-Type multipart/form-data` - with a real multipart as body: ``` -----------------------------9051914041544843365972754266 Content-Disposition: form-data; name="text" text default -----------------------------9051914041544843365972754266 Content-Disposition: form-data; name="file1"; filename="a.txt" Content-Type: text/plain Content of a txt -----------------------------9051914041544843365972754266 Content-Disposition: form-data; name="file2"; filename="a.html" Content-Type: text/html <!DOCTYPE html><title>Content of a.html.</title> -----------------------------9051914041544843365972754266-- ``` > can you try this? --- But in this case, I think that an exception is thrown, this should be fixed.
Author
Owner

@StefH commented on GitHub (May 16, 2025):

https://github.com/wiremock/WireMock.Net/pull/1297

@StefH commented on GitHub (May 16, 2025): https://github.com/wiremock/WireMock.Net/pull/1297
Author
Owner

@AntoineBriseboisRoy commented on GitHub (May 21, 2025):

Any news on that?

@AntoineBriseboisRoy commented on GitHub (May 21, 2025): Any news on that?
Author
Owner

@StefH commented on GitHub (May 22, 2025):

@AntoineBriseboisRoy
PR is merged; I'll create a new NuGet today

@StefH commented on GitHub (May 22, 2025): @AntoineBriseboisRoy PR is merged; I'll create a new NuGet today
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#693