mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 08:59:50 +01:00
Restricted ResponseHeaders (#126)
This commit is contained in:
@@ -545,6 +545,24 @@ namespace WireMock.Net.Tests
|
||||
Check.That(response).IsEqualTo("/fooBar");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FluentMockServer_Should_IgnoreRestrictedHeader()
|
||||
{
|
||||
// Assign
|
||||
_server = FluentMockServer.Start();
|
||||
_server
|
||||
.Given(Request.Create().WithPath("/head").UsingHead())
|
||||
.RespondWith(Response.Create().WithHeader("Content-Length", "1024"));
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Head, "http://localhost:" + _server.Ports[0] + "/head");
|
||||
|
||||
// Act
|
||||
var response = await new HttpClient().SendAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(response.Content.Headers.GetValues("Content-Length")).ContainsExactly("0");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_server?.Stop();
|
||||
|
||||
26
test/WireMock.Net.Tests/ResponseTests.cs
Normal file
26
test/WireMock.Net.Tests/ResponseTests.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using NFluent;
|
||||
using WireMock.ResponseBuilders;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class ResponseTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Fact]
|
||||
public async void Response_Create_WithHeader_ContentLength()
|
||||
{
|
||||
// Assign
|
||||
var requestMock = new RequestMessage(new Uri("http://localhost/foo"), "PUT", ClientIp);
|
||||
IResponseBuilder builder = Response.Create().WithHeader("Content-Length", "1024");
|
||||
|
||||
// Act
|
||||
var response = await builder.ProvideResponseAsync(requestMock);
|
||||
|
||||
// Assert
|
||||
Check.That(response.Headers["Content-Length"].ToString()).Equals("1024");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user