Owin.Response.GetHeader C# (CSharp) Method

GetHeader() public method

Returns the first value of the given header or null if the header does not exist
public GetHeader ( string key ) : string
key string
return string
        public virtual string GetHeader(string key)
        {
            key = key.ToLower(); // <--- instead of doing this everywhere, it would be ideal if the Headers IDictionary could do this by itself!
            if (! Headers.ContainsKey(key))
                return null;
            else {
                string value = null;
                foreach (string headerValue in Headers[key]) {
                    value = headerValue;
                    break;
                }
                return value;
            }
        }

Usage Example

Esempio n. 1
0
 public void ItFormatsTheCookieExpirationDataAccordinglyToRfc2109()
 {
     var response = new Response();
     response.SetCookie("foo", new Response.Cookie { Value = "bar", Expires = new DateTime(1971, 10, 14, 12, 34, 56) });
     Assert.That(response.GetHeader("Set-Cookie"), Is.StringMatching(@"expires=..., \d\d-...-\d\d\d\d \d\d:\d\d:\d\d ..."));
 }