using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using WireMock.Util; using WireMock.Validation; namespace WireMock { /// /// The response. /// public class ResponseMessage { /// /// Gets the headers. /// public IDictionary> Headers { get; set; } = new ConcurrentDictionary>(); /// /// Gets or sets the status code. /// public int StatusCode { get; set; } = 200; /// /// Gets or sets the body. /// public string BodyOriginal { get; set; } /// /// Gets or sets the body destination (SameAsSource, String or Bytes). /// public string BodyDestination { get; set; } /// /// Gets or sets the body as a string. /// public string Body { get; set; } /// /// Gets or sets the body as bytes. /// public byte[] BodyAsBytes { get; set; } /// /// Gets or sets the body as a file. /// public string BodyAsFile { get; set; } /// /// Is the body as file cached? /// public bool? BodyAsFileIsCached { get; set; } /// /// Gets or sets the body encoding. /// public Encoding BodyEncoding { get; set; } = new UTF8Encoding(false); /// /// Adds the header. /// /// The name. /// The value. public void AddHeader(string name, string value) { Headers.Add(name, new WireMockList(value)); } /// /// Adds the header. /// /// The name. /// The values. public void AddHeader(string name, params string[] values) { Check.NotEmpty(values, nameof(values)); var newHeaderValues = Headers.TryGetValue(name, out WireMockList existingValues) ? values.Union(existingValues).ToArray() : values; Headers[name] = new WireMockList(newHeaderValues); } } }