When proxying, the Content-Type headers get dropped from the request #147

Closed
opened 2025-12-29 14:23:33 +01:00 by adam · 9 comments
Owner

Originally created by @alefranz on GitHub (Oct 8, 2018).

I'm using the Proxy and Capture functionality but when I do a POST with body, the Content-Type header of the request doesn't get passed to the proxyed service

Originally created by @alefranz on GitHub (Oct 8, 2018). I'm using the Proxy and Capture functionality but when I do a POST with body, the `Content-Type` header of the request doesn't get passed to the proxyed service
adam closed this issue 2025-12-29 14:23:33 +01:00
Author
Owner

@alefranz commented on GitHub (Oct 8, 2018):

It looks like there is a specific test for this:
f358f13c08/test/WireMock.Net.Tests/FluentMockServerTests.Proxy.cs (L45)

however I'm on 1.0.4.17 but experiencing the issue

@alefranz commented on GitHub (Oct 8, 2018): It looks like there is a specific test for this: https://github.com/WireMock-Net/WireMock.Net/blob/f358f13c0839de275f45e6aa756bd14c92ef20fa/test/WireMock.Net.Tests/FluentMockServerTests.Proxy.cs#L45 however I'm on 1.0.4.17 but experiencing the issue
Author
Owner

@alefranz commented on GitHub (Oct 8, 2018):

However that test run only on full framework why I'm experiencing the issue in .NET Core.
Is it a known limitation with .NET Core?

@alefranz commented on GitHub (Oct 8, 2018): However that test run only on full framework why I'm experiencing the issue in .NET Core. Is it a known limitation with .NET Core?
Author
Owner

@StefH commented on GitHub (Oct 8, 2018):

I'll check. Thanks for reporting.

@StefH commented on GitHub (Oct 8, 2018): I'll check. Thanks for reporting.
Author
Owner

@StefH commented on GitHub (Oct 9, 2018):

About the unit-tests : for some reason starting a .NET Core instance from WireMock in a unit-test blocks, as where in .NET Framework 4.5.2, it just starts and listens requests.

However testing the WithProxy(...) shows that all works.
660e97a4ce/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithProxyTests.cs

Can you maybe provide an example mapping in c# or .json which reproduces your issue?

@StefH commented on GitHub (Oct 9, 2018): About the unit-tests : for some reason starting a .NET Core instance from WireMock in a unit-test blocks, as where in .NET Framework 4.5.2, it just starts and listens requests. However testing the `WithProxy(...)` shows that all works. https://github.com/WireMock-Net/WireMock.Net/blob/660e97a4ce2c5e811dffe730141328d04013846e/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithProxyTests.cs Can you maybe provide an example mapping in c# or .json which reproduces your issue?
Author
Owner

@StefH commented on GitHub (Oct 9, 2018):

I just did some testing with example application WireMock.Net.Console.NETCoreApp2, file MainApp.cs

Modified the c# code like this:

server
	.Given(Request.Create()
		.UsingPost()
		.WithHeader("postmanecho", "post")
	)
	.RespondWith(Response.Create()
		.WithProxy(new ProxyAndRecordSettings { Url = "http://postman-echo.com/post" })
	);

server
	.Given(Request.Create()
		.UsingGet()
		.WithHeader("postmanecho", "get")
	)
	.RespondWith(Response.Create()
		.WithProxy(new ProxyAndRecordSettings { Url = "http://postman-echo.com/get" })

When doing a POST to the url http://{{wm_hostname}}/post I get this:
postman

So it seems that the header is correctly passed to the proxy (postman-echo.com)

@StefH commented on GitHub (Oct 9, 2018): I just did some testing with example application **WireMock.Net.Console.NETCoreApp2**, file `MainApp.cs` Modified the c# code like this: ``` c# server .Given(Request.Create() .UsingPost() .WithHeader("postmanecho", "post") ) .RespondWith(Response.Create() .WithProxy(new ProxyAndRecordSettings { Url = "http://postman-echo.com/post" }) ); server .Given(Request.Create() .UsingGet() .WithHeader("postmanecho", "get") ) .RespondWith(Response.Create() .WithProxy(new ProxyAndRecordSettings { Url = "http://postman-echo.com/get" }) ``` When doing a POST to the url `http://{{wm_hostname}}/post` I get this: ![postman](https://user-images.githubusercontent.com/249938/46677290-a4a31a00-cbe2-11e8-9413-06e1aa2abf95.png) So it seems that the header is correctly passed to the proxy (postman-echo.com)
Author
Owner

@alefranz commented on GitHub (Oct 10, 2018):

Apologies for the delay.
Many thanks for spending time looking into my issue.

You can reproduce my issue with the test app using a custom mediatype like application/vnd.contoso+json

image

@alefranz commented on GitHub (Oct 10, 2018): Apologies for the delay. Many thanks for spending time looking into my issue. You can reproduce my issue with the test app using a custom mediatype like `application/vnd.contoso+json` ![image](https://user-images.githubusercontent.com/348793/46751968-f5367800-ccb3-11e8-9109-dc179ead8fc6.png)
Author
Owner

@StefH commented on GitHub (Oct 11, 2018):

Can you please try version 1.0.4.18-preview-02 from MyGet feed : https://www.myget.org/F/wiremock-net/api/v3/index.json

I did change some code regarding this logic.

@StefH commented on GitHub (Oct 11, 2018): Can you please try version `1.0.4.18-preview-02` from MyGet feed : https://www.myget.org/F/wiremock-net/api/v3/index.json I did change some code regarding this logic.
Author
Owner

@alefranz commented on GitHub (Oct 15, 2018):

I can't find that specific version, however it works correctly on 1.0.4.18-ci-1343
Thank you!

@alefranz commented on GitHub (Oct 15, 2018): I can't find that specific version, however it works correctly on 1.0.4.18-ci-1343 Thank you!
Author
Owner

@StefH commented on GitHub (Oct 15, 2018):

OK Thanks for testing.

@StefH commented on GitHub (Oct 15, 2018): OK Thanks for testing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#147