Added support for raw Output Headers

This commit is contained in:
Stef Heyenrath
2017-03-06 14:29:01 +01:00
parent c8920c6356
commit b09b882ad1
2 changed files with 18 additions and 0 deletions

View File

@@ -63,6 +63,14 @@ namespace WireMock.Admin.Mappings
/// </value>
public IDictionary<string, string> Headers { get; set; }
/// <summary>
/// Gets or sets the Headers (Raw).
/// </summary>
/// <value>
/// The Headers (Raw).
/// </value>
public string HeadersRaw { get; set; }
/// <summary>
/// Gets or sets the delay in milliseconds.
/// </summary>

View File

@@ -429,6 +429,16 @@ namespace WireMock.Server
if (responseModel.Headers != null)
responseBuilder = responseBuilder.WithHeaders(responseModel.Headers);
else if (responseModel.HeadersRaw != null)
{
foreach (string headerLine in responseModel.HeadersRaw.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
{
int indexColon = headerLine.IndexOf(":", StringComparison.Ordinal);
string key = headerLine.Substring(0, indexColon).TrimStart(' ', '\t');
string value = headerLine.Substring(indexColon + 1).TrimStart(' ', '\t');
responseBuilder = responseBuilder.WithHeader(key, value);
}
}
if (responseModel.Body != null)
responseBuilder = responseBuilder.WithBody(responseModel.Body, ToEncoding(responseModel.BodyEncoding));