Beispiel #1
0
        public void SetHeaders(HeaderList AHeaders)
        {
            string S = "";

            if (_Authentication != null)
            {
                S = _Authentication.Authentication();
                if (S.Length > 0)
                {
                    AHeaders.Values("Proxy-Authentication", S);
                }
            }
            else
            {
                if (_BasicByDefault)
                {
                    _Authentication          = new BasicAuthentication();
                    _Authentication.UserName = _UserName;
                    _Authentication.Password = _Password;
                    S = _Authentication.Authentication();
                    if (S.Length > 0)
                    {
                        AHeaders.Values("Proxy-Authentication", S);
                    }
                }
            }
        }
        protected override void DoSetHeaders()
        {
            base.DoSetHeaders();

            if (_ProxyConnection.Length > 0)
            {
                _RawHeaders.Values("Proxy-Connection", _ProxyConnection);
            }
            if (_Host.Length > 0)
            {
                _RawHeaders.Values("Host", _Host);
            }
            if (_Accept.Length > 0)
            {
                _RawHeaders.Values("Accept", _Accept);
            }
            if (_AcceptCharSet.Length > 0)
            {
                _RawHeaders.Values("Accept-Charset", _AcceptCharSet);
            }
            if (_AcceptEncoding.Length > 0)
            {
                _RawHeaders.Values("Accept-Language", _AcceptLanguage);
            }
            if (_From.Length > 0)
            {
                _RawHeaders.Values("From", _From);
            }
            if (_Referer.Length > 0)
            {
                _RawHeaders.Values("Referer", _Referer);
            }
            if (_UserAgent.Length > 0)
            {
                _RawHeaders.Values("User-Agent", _UserAgent);
            }
            if (_LastModified.Ticks > 0)
            {
                _RawHeaders.Values("If-Modified-Since", Http.DateTimeGmtToHttpStr(_LastModified));
            }
            if (_ContentRangeStart != 0 ||
                _ContentRangeEnd != 0)
            {
                if (_ContentRangeEnd != 0)
                {
                    _RawHeaders.Values("Range", "bytes=" + _ContentRangeStart.ToString() + "-" + _ContentRangeEnd.ToString());
                }
                else
                {
                    _RawHeaders.Values("Range", "bytes=" + _ContentRangeStart.ToString() + "-");
                }
            }
            if (_Authentication != null)
            {
                string S = _Authentication.Authentication();
                if (S.Length > 0)
                {
                    _RawHeaders.Values("Authorization", S);
                }
            }
            else
            {
                if (_BasicByDefault)
                {
                    _Authentication          = new BasicAuthentication();
                    _Authentication.UserName = _UserName;
                    _Authentication.Password = _Password;
                    string S = _Authentication.Authentication();
                    if (S.Length > 0)
                    {
                        _RawHeaders.Values("Authorization", S);
                    }
                }
            }
        }