예제 #1
0
 /// <summary>
 /// Adds User-Agent information to the specified headers map.
 /// </summary>
 /// <param name="headers">A map of headers to be updated with user-agent information.</param>
 public static void AddUserAgentToHeader(Dictionary<string, string> headers, string name, string version)
 {
     UserAgentHeader userAgentHeader = new UserAgentHeader(name, version);
     foreach (KeyValuePair<string, string> item in userAgentHeader.GetHeader())
     {
         headers[item.Key] = item.Value;
     }
 }
            public void Must_parse_correctly(object[] parameters)
            {
                var headerValue = (string)parameters[0];
                IEnumerable <string>          products = parameters.Where((arg, i) => i > 0).Cast <string>();
                IEnumerable <UserAgentHeader> headers  = UserAgentHeader.ParseMany(headerValue);

                Assert.That(headers.Select(arg => arg.Product), Is.EquivalentTo(products));
            }
예제 #3
0
        /// <summary>
        /// Adds User-Agent information to the specified headers map.
        /// </summary>
        /// <param name="headers">A map of headers to be updated with user-agent information.</param>
        public static void AddUserAgentToHeader(Dictionary <string, string> headers, string name, string version)
        {
            UserAgentHeader userAgentHeader = new UserAgentHeader(name, version);

            foreach (KeyValuePair <string, string> item in userAgentHeader.GetHeader())
            {
                headers[item.Key] = item.Value;
            }
        }
예제 #4
0
        public void VerifyUserAgentHeader()
        {
            var userAgent = new UserAgentHeader("test-product", "1.5.0");
            var header    = userAgent.GetHeader();

            Assert.IsTrue(header.ContainsKey(BaseConstants.UserAgentHeader));
            var userAgentString = userAgent.GetHeader()[BaseConstants.UserAgentHeader];

            Assert.IsTrue(userAgentString.StartsWith("PayPalSDK/test-product 1.5.0"));
        }
예제 #5
0
        public Destiny2Api(String Key, UserAgentHeader Header)
        {
            ApiKey           = Key;
            UserAgent        = Header;
            _Web.BaseAddress = new Uri(ApiRootPath);
            _Web.DefaultRequestHeaders.Add("X-API-Key", ApiKey);
            _Web.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", UserAgent.ToString());
            _Web.DefaultRequestHeaders.Add("Accept", "applicaiton/json");

            InitDataWithoutPath(Environment.CurrentDirectory);
        }
예제 #6
0
        public Destiny2Api(String Key, UserAgentHeader Header, String DB_Path)
        {
            ApiKey           = Key;
            UserAgent        = Header;
            _Web.BaseAddress = new Uri(ApiRootPath);
            _Web.DefaultRequestHeaders.Add("X-API-Key", ApiKey);
            _Web.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", UserAgent.ToString());
            _Web.DefaultRequestHeaders.Add("Accept", "applicaiton/json");

            DataEngine = new SQLiteDestinyEngine(new FileInfo(DB_Path));
        }
예제 #7
0
 private void CreateCommonHeaders(SipUser sipUser, LocalSipUserAgentServer localSipUas, SipTransportManager sipTransportManager)
 {
     this.viaHeader     = new ViaHeader(localSipUas, sipTransportManager.SipProtocol, sipTransportManager.SipTransport);
     this.fromHeader    = new FromHeader(sipUser, localSipUas, sipTransportManager.SipProtocol);
     this.toHeader      = new ToHeader(localSipUas, sipTransportManager.SipProtocol);
     this.callIdHeader  = new CallIdHeader();
     this.contactHeader = new ContactHeader(localSipUas, sipTransportManager.SipProtocol);
     this.routeHeader   = new RouteHeader(localSipUas, sipTransportManager.SipProtocol);
     this.userAgent     = new UserAgentHeader();
     this.expiresHeader = new ExpiresHeader();
     this.maxForwards   = new MaxForwardsHeader();
     this.allowHeader   = new AllowHeader();
     this.contentLength = new ContentLength(body);
 }
 public void Must_not_result_in_header(string headerValue)
 {
     Assert.That(UserAgentHeader.ParseMany(headerValue), Is.Empty);
 }