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

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

Closed
alefranz opened this issue Oct 8, 2018 · 9 comments
Closed

Comments

@alefranz
Copy link

alefranz commented 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

@alefranz
Copy link
Author

alefranz commented Oct 8, 2018

It looks like there is a specific test for this:

public async Task FluentMockServer_Proxy_Should_preserve_content_header_in_proxied_request()

however I'm on 1.0.4.17 but experiencing the issue

@alefranz
Copy link
Author

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

@StefH
Copy link
Collaborator

StefH commented Oct 8, 2018

I'll check. Thanks for reporting.

@StefH
Copy link
Collaborator

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

@StefH
Copy link
Collaborator

StefH commented 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)

@alefranz
Copy link
Author

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

@StefH
Copy link
Collaborator

StefH commented 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.

@alefranz
Copy link
Author

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

@StefH
Copy link
Collaborator

StefH commented Oct 15, 2018

OK Thanks for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants