Exemplo n.º 1
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        /// <param name="response"></param>
        /// <param name="collection"></param>
        public HeadersWrapper_Response(IHttpListenerResponse response) : base(StringComparer.OrdinalIgnoreCase)
        {
            _Response = response;

            _DoingInitialCopy = true;
            try {
                foreach (var key in response.Headers.AllKeys)
                {
                    var value = response.Headers[key];
                    base[key] = HeadersDictionary.SplitRawHeaderValue(value).ToArray();
                }
            } finally {
                _DoingInitialCopy = false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 执行与释放或重置非托管资源相关的应用程序定义的任务。
 /// </summary>
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     if (_request != null)
     {
         _request.Dispose();
         _request = null;
     }
     if (_response != null)
     {
         _response.Dispose();
         _response = null;
     }
     _disposed = true;
 }
Exemplo n.º 3
0
        public static int GetResponseHeaderLength(IHttpListenerResponse response)
        {
            int length = 0;
            WebHeaderCollection headers = response.Headers;

            if (headers != null)
            {
                string[] allKeys = headers.AllKeys;
                for (int i = 0; i < (int)allKeys.Length; i++)
                {
                    string str = allKeys[i];
                    length += str.Length;
                    string str1 = headers.Get(str);
                    if (str1 != null)
                    {
                        length += str1.Length;
                    }
                }
            }
            return(length);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 创建HttpListenerContext实例。
 /// </summary>
 /// <param name="request"></param>
 /// <param name="response"></param>
 public HttpListenerContext(IHttpListenerRequest request, IHttpListenerResponse response)
 {
     _request  = request;
     _response = response;
 }