Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Modules/ReverseProxy/Http/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ private HttpRequestMessage ConfigureRequest(IRequest request)

var req = new HttpRequestMessage(new HttpMethod(request.Header.Method.ToString()), GetRequestUri(request));

// important: set the body before the header so we can override "Content-" related headers here
var content = request.GetBody();

if (content is not null && CanSendBody(request))
{
req.Content = new RequestBody(content);
}

for (var i = 0; i < headers.Count; i++)
{
var header = headers.GetStringEntry(i);
Expand Down Expand Up @@ -119,13 +127,6 @@ private HttpRequestMessage ConfigureRequest(IRequest request)

req.Headers.Add("Forwarded", string.Join(", ", forwardings.Select(GetForwarding)));

var content = request.GetBody();

if (content is not null && CanSendBody(request))
{
req.Content = new RequestBody(content);
}

return req;
}

Expand Down
20 changes: 20 additions & 0 deletions Testing/Acceptance/Modules/ReverseProxy/ReverseProxyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ public async Task TestHead(ServerEngine engine)
await headed.AssertStatusAsync(HttpStatusCode.OK);
}

[TestMethod]
[MultiEngineTest]
public async Task TestContentTypeIsRelayed(ServerEngine engine)
{
await using var setup = await TestSetup.CreateAsync(engine, r =>
{
var contentType = r.Header.Headers.GetEntry("Content-Type");
return r.Respond().Content(contentType ?? "(none)").Build();
});

var runner = setup.Runner;

var request = runner.GetRequest(method: new HttpMethod("SEARCH"));
request.Content = new StringContent("<x/>", System.Text.Encoding.UTF8, "application/xml");

using var response = await runner.GetResponseAsync(request);

Assert.AreEqual("application/xml; charset=utf-8", await response.GetContentAsync());
}

[TestMethod]
[MultiEngineTest]
public async Task TestForwardingChainIsRelayed(ServerEngine engine)
Expand Down
Loading