using System.Collections.Generic; using System.Linq; using System.Text; using WireMock.Util; using WireMock.Validation; namespace WireMock { /// /// The ResponseMessage. /// public class ResponseMessage { /// /// Gets the headers. /// public IDictionary> Headers { get; set; } = new Dictionary>(); /// /// 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 a json object. /// public object BodyAsJson { get; set; } /// /// Gets or sets a value indicating whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings. /// public bool? BodyAsJsonIndented { 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.NotNullOrEmpty(values, nameof(values)); var newHeaderValues = Headers.TryGetValue(name, out WireMockList existingValues) ? values.Union(existingValues).ToArray() : values; Headers[name] = new WireMockList(newHeaderValues); } } }