Ejemplo n.º 1
0
        internal RequestViewModel(HttpChannel channel, bool isResponse)
        {
            _Channel = new WeakReference <nsIHttpChannel>(channel.Instance);
            Method   = channel.RequestMethod;
            Url      = channel.Uri;

            RequestHeaders = Array.AsReadOnly(
                channel.GetRequestHeadersDict()
                .SelectMany(e => e.Value.Select(s => new KeyValuePair <string, string>(e.Key, s)))
                .ToArray());

            if (isResponse)
            {
                _StatusCode    = (int)channel.ResponseStatus;
                _ContentType   = channel.ContentType;
                _ContentLength = channel.ContentLength >= 0 ? channel.ContentLength : (long?)null;

                ResponseHeaders = Array.AsReadOnly(
                    channel.GetResponseHeadersDict()
                    .SelectMany(e => e.Value.Select(s => new KeyValuePair <string, string>(e.Key, s)))
                    .ToArray());
            }
        }