Exemplo n.º 1
0
        public IHttpMultiClient AddCookie(Action <CookieOption> action)
        {
            if (Client != null)
            {
                throw new Exception("Client已初始化,不能再添加认证信息");
            }

            CookieOption Option = new CookieOption();

            action(Option);
            Container = Option.SetCookie(Container);
            if (Container == null)
            {
                throw new Exception("Cookie异常,认证信息不能为空");
            }
            return(this);
        }
Exemplo n.º 2
0
    internal override void ParseRecordData(ReadOnlySpan <byte> resultData, int startPosition, int length)
    {
        int endPosition = startPosition + length;

        Options = new List <EDnsOptionBase>();
        while (startPosition < endPosition)
        {
            EDnsOptionType type       = (EDnsOptionType)DnsMessageBase.ParseUShort(resultData, ref startPosition);
            ushort         dataLength = DnsMessageBase.ParseUShort(resultData, ref startPosition);

            EDnsOptionBase option;

            switch (type)
            {
            case EDnsOptionType.LongLivedQuery:
                option = new LongLivedQueryOption();
                break;

            case EDnsOptionType.UpdateLease:
                option = new UpdateLeaseOption();
                break;

            case EDnsOptionType.NsId:
                option = new NsIdOption();
                break;

            case EDnsOptionType.Owner:
                option = new OwnerOption();
                break;

            case EDnsOptionType.DnssecAlgorithmUnderstood:
                option = new DnssecAlgorithmUnderstoodOption();
                break;

            case EDnsOptionType.DsHashUnderstood:
                option = new DsHashUnderstoodOption();
                break;

            case EDnsOptionType.Nsec3HashUnderstood:
                option = new Nsec3HashUnderstoodOption();
                break;

            case EDnsOptionType.ClientSubnet:
                option = new ClientSubnetOption();
                break;

            case EDnsOptionType.Expire:
                option = new ExpireOption();
                break;

            case EDnsOptionType.Cookie:
                option = new CookieOption();
                break;

            default:
                option = new UnknownOption(type);
                break;
            }

            option.ParseData(resultData, startPosition, dataLength);
            Options.Add(option);
            startPosition += dataLength;
        }
    }