コード例 #1
0
        protected override void OnAssigned(string key, string[] value)
        {
            if (!_DoingInitialCopy)
            {
                switch ((key ?? "").ToLower())
                {
                case "content-length":
                    _Response.ContentLength64 = Parser.ParseInt64(HeadersDictionary.JoinCookedHeaderValues(value)) ?? 0L;
                    break;

                case "keep-alive":
                    _Response.KeepAlive = Parser.ParseBool(HeadersDictionary.JoinCookedHeaderValues(value)) ?? true;
                    break;

                case "transfer-encoding":
                    if (
                        (value ?? new string[0])
                        .Any(r => (r ?? "").Trim().ToLower() == "chunked")
                        )
                    {
                        _Response.SendChunked = true;
                    }
                    break;

                case "www-authenticate":
                    _Response.AddHeader("WWW-Authenticate", HeadersDictionary.JoinCookedHeaderValues(value));
                    break;

                default:
                    _Response.Headers[key] = HeadersDictionary.JoinCookedHeaderValues(value);
                    break;
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public virtual string[] this[string key]
 {
     get {
         var headerValue = _Collection[key];
         return(headerValue == null
             ? null
             : HeadersDictionary.SplitRawHeaderValue(headerValue)?.ToArray());
     }
     set {
         if (key == null)
         {
             throw new ArgumentNullException(nameof(key));
         }
         _Collection[key] = HeadersDictionary.JoinCookedHeaderValues(value);
     }
 }
コード例 #3
0
        public void Static_SplitRawHeaderValue_Round_Trips_With_JoinCookedHeaderValues(string [] splitValues, string headerValue)
        {
            var splitHeaderValues = HeadersDictionary.SplitRawHeaderValue(headerValue);

            if (splitValues == null)
            {
                Assert.IsNull(splitHeaderValues);
            }
            else
            {
                Assert.IsTrue(splitValues.SequenceEqual(splitHeaderValues));
            }

            var rejoinedHeader = HeadersDictionary.JoinCookedHeaderValues(splitHeaderValues);

            if (headerValue == null)
            {
                Assert.IsNull(rejoinedHeader);
            }
            else
            {
                Assert.AreEqual(headerValue, rejoinedHeader);
            }
        }
コード例 #4
0
        public void Static_JoinCookedHeaderValues_Ignores_Null_And_Empty_Values(string[] rawStringArray, string expected)
        {
            var actual = HeadersDictionary.JoinCookedHeaderValues(rawStringArray);

            Assert.AreEqual(expected, actual);
        }