mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-10 19:27:09 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -62,7 +62,7 @@ namespace WireMock.Http
|
|||||||
var httpRequestMessage = new HttpRequestMessage(new HttpMethod(requestMessage.Method), url);
|
var httpRequestMessage = new HttpRequestMessage(new HttpMethod(requestMessage.Method), url);
|
||||||
|
|
||||||
// Set Body if present
|
// Set Body if present
|
||||||
if (requestMessage.BodyAsBytes != null && requestMessage.BodyAsBytes.Length > 0)
|
if (requestMessage.BodyAsBytes != null)
|
||||||
{
|
{
|
||||||
httpRequestMessage.Content = new ByteArrayContent(requestMessage.BodyAsBytes);
|
httpRequestMessage.Content = new ByteArrayContent(requestMessage.BodyAsBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,37 @@ namespace WireMock.Net.Tests
|
|||||||
Check.That(receivedRequest.Headers["Content-Type"]).ContainsExactly("text/plain");
|
Check.That(receivedRequest.Headers["Content-Type"]).ContainsExactly("text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task FluentMockServer_Should_preserve_content_header_in_proxied_request_with_empty_content()
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
_serverForProxyForwarding = FluentMockServer.Start();
|
||||||
|
_serverForProxyForwarding
|
||||||
|
.Given(Request.Create().WithPath("/*"))
|
||||||
|
.RespondWith(Response.Create());
|
||||||
|
|
||||||
|
_server = FluentMockServer.Start();
|
||||||
|
_server
|
||||||
|
.Given(Request.Create().WithPath("/*"))
|
||||||
|
.RespondWith(Response.Create().WithProxy(_serverForProxyForwarding.Urls[0]));
|
||||||
|
|
||||||
|
// when
|
||||||
|
var requestMessage = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Post,
|
||||||
|
RequestUri = new Uri(_server.Urls[0]),
|
||||||
|
Content = new StringContent("")
|
||||||
|
};
|
||||||
|
requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
|
||||||
|
await new HttpClient().SendAsync(requestMessage);
|
||||||
|
|
||||||
|
// then
|
||||||
|
var receivedRequest = _serverForProxyForwarding.LogEntries.First().RequestMessage;
|
||||||
|
Check.That(receivedRequest.Body).IsEqualTo("");
|
||||||
|
Check.That(receivedRequest.Headers).ContainsKey("Content-Type");
|
||||||
|
Check.That(receivedRequest.Headers["Content-Type"]).ContainsExactly("text/plain");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task FluentMockServer_Should_preserve_content_header_in_proxied_response()
|
public async Task FluentMockServer_Should_preserve_content_header_in_proxied_response()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user