public void Should_Check_Existence_of_Keys_Case_Insensitively() { var headers = new HeaderHash(new Hash { { "Content-MD5", "d5ff4e2a0 ..." } }); Assert.IsTrue(headers.ContainsKey("content-md5")); Assert.IsFalse(headers.ContainsKey("ETag")); }
public void Should_Be_Able_To_Delete_The_Given_Key_Case_Insensitively() { var headers = new HeaderHash(new Hash { { "foo", "bar" } }); headers.Remove("FOO"); Assert.IsFalse(headers.ContainsKey("foo")); Assert.IsFalse(headers.ContainsKey("FOO")); }
public dynamic[] Call(IDictionary <string, dynamic> environment) { var response = _app.Call(environment); var headers = new HeaderHash(response[1]); if (!headers.ContainsKey("Content-Type") || headers["Content-Type"] == null) { headers["Content-Type"] = _contentType; } return(new[] { response[0], headers, response[2] }); }
public Response(dynamic body = null, int status = 200, Hash header = null, Action <dynamic> block = null) { if (body == null) { body = new List <dynamic>(); } if (header == null) { header = new Hash(); } Headers = new HeaderHash(new Hash { { "Content-Type", "text/html" } }).Merge(header); Status = status; Body = new List <dynamic>(); Writer = str => Body.Add(str); if (Headers.ContainsKey("Transfer-Encoding") && Headers["Transfer-Encoding"] == "chunked") { Chunked = true; } if (body is string) { Write(body); } else if (body is IEnumerable) { new IterableAdapter(body).Each(part => Write(part.ToString())); } else { throw new ArgumentException("Must be iterable.", "body"); } if (block != null) { block(this); } }