public string Uri() { Dictionary <string, string> query = null; query = Query == null ? new Dictionary <string, string>() : new Dictionary <string, string>(Query); var schema = Secure ? "wss" : "ws"; var portString = ""; if (TimestampRequests) { query.Add(TimestampParam, DateTime.Now.Ticks + "-" + Timestamps++); } var _query = ParseQS.Encode(query); if (Port > 0 && ("wss" == schema && Port != 443 || "ws" == schema && Port != 80)) { portString = ":" + Port; } if (_query.Length > 0) { _query = "?" + _query; } return(schema + "://" + Hostname + portString + Path + _query); }
public void Encode() { LogManager.SetupLogManager(); var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()); log.Info("Start"); Dictionary <string, string> obj; obj = new Dictionary <string, string> { { "a", "b" } }; var imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b"); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "d" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b&c=d"); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "tobi rocks" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b&c=tobi%20rocks"); }
public string Uri() { //var query = this.Query; var query = new Dictionary <string, string>(Query); //if (Query == null) //{ // query = new Dictionary<string, string>(); //} var schema = Secure ? "https" : "http"; var portString = ""; if (TimestampRequests) { query.Add(TimestampParam, DateTime.Now.Ticks + "-" + Timestamps++); } query.Add("b64", "1"); var _query = ParseQS.Encode(query); if (Port > 0 && ("https" == schema && Port != 443 || "http" == schema && Port != 80)) { portString = ":" + Port; } if (_query.Length > 0) { _query = "?" + _query; } return(schema + "://" + Hostname + portString + Path + _query); }
public string Uri() { //var query = this.Query; var query = new Dictionary <string, string>(Query); //if (Query == null) //{ // query = new Dictionary<string, string>(); //} string schema = this.Secure ? "https" : "http"; string portString = ""; if (this.TimestampRequests) { query.Add(this.TimestampParam, DateTime.Now.Ticks + "-" + Transport.Timestamps++); } query.Add("b64", "1"); string _query = ParseQS.Encode(query); if (this.Port > 0 && (("https" == schema && this.Port != 443) || ("http" == schema && this.Port != 80))) { portString = ":" + this.Port; } if (_query.Length > 0) { _query = "?" + _query; } return(schema + "://" + this.Hostname + portString + this.Path + _query); }
public void Encode() { var log = LogManager.GetLogger(Global.CallerName()); log.Info("Start"); Dictionary <string, string> obj; obj = new Dictionary <string, string> { { "a", "b" } }; var imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b"); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "d" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b&c=d"); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "tobi rocks" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.AreEqual(ParseQS.Encode(imObj), "a=b&c=tobi%20rocks"); }
public string Uri() { Dictionary <string, string> query = null; query = this.Query == null ? new Dictionary <string, string>() : new Dictionary <string, string>(this.Query); var schema = this.Secure ? "wss" : "ws"; var portString = ""; if (this.TimestampRequests) { query.Add(this.TimestampParam, DateTime.Now.Ticks.ToString() + "-" + Transport.Timestamps++); } var _query = ParseQS.Encode(query); if (this.Port > 0 && (("wss" == schema && this.Port != 443) || ("ws" == schema && this.Port != 80))) { portString = ":" + this.Port; } if (_query.Length > 0) { _query = "?" + _query; } return(schema + "://" + this.Hostname + portString + this.Path + _query); }
public void Decode() { // Single assignment var queryObj = ParseQS.Decode("foo=bar"); Assert.Equal("bar", queryObj["foo"]); // Multiple assignments queryObj = ParseQS.Decode("france=grenoble&germany=mannheim"); Assert.Equal("grenoble", queryObj["france"]); Assert.Equal("mannheim", queryObj["germany"]); // Assignments containing non-alphanumeric characters queryObj = ParseQS.Decode("india=new%20delhi"); Assert.Equal("new delhi", queryObj["india"]); }
public Socket(Options options) { if (options.Host != null) { var pieces = options.Host.Split(':'); options.Hostname = pieces[0]; if (pieces.Length > 1) { options.Port = int.Parse(pieces[pieces.Length - 1]); } } _secure = options.Secure; _sslProtocols = options.SslProtocols; _hostname = options.Hostname; _port = options.Port; _query = options.QueryString != null ? ParseQS.Decode(options.QueryString) : new Dictionary <string, string>(); if (options.Query != null) { foreach (var item in options.Query) { _query.Add(item.Key, item.Value); } } _upgrade = options.Upgrade; _path = (options.Path ?? "/engine.io").Replace("/$", "") + "/"; _timestampParam = options.TimestampParam ?? "t"; _timestampRequests = options.TimestampRequests; _transports = options.Transports ?? ImmutableList <string> .Empty.Add(Polling.NAME).Add(WebSocket.NAME); _policyPort = options.PolicyPort != 0 ? options.PolicyPort : 843; _rememberUpgrade = options.RememberUpgrade; _cookies = options.Cookies; if (options.IgnoreServerCertificateValidation) { ServerCertificate.IgnoreServerCertificateValidation(); } ExtraHeaders = options.ExtraHeaders; }
public void Decode() { var log = LogManager.GetLogger(Global.CallerName()); log.Info("Start"); // Single assignment var queryObj = ParseQS.Decode("foo=bar"); Assert.AreEqual(queryObj["foo"], "bar"); // Multiple assignments queryObj = ParseQS.Decode("france=grenoble&germany=mannheim"); Assert.AreEqual(queryObj["france"], "grenoble"); Assert.AreEqual(queryObj["germany"], "mannheim"); // Assignments containing non-alphanumeric characters queryObj = ParseQS.Decode("india=new%20delhi"); Assert.AreEqual(queryObj["india"], "new delhi"); }
public void Decode() { LogManager.SetupLogManager(); var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()); log.Info("Start"); // Single assignment var queryObj = ParseQS.Decode("foo=bar"); Assert.AreEqual(queryObj["foo"], "bar"); // Multiple assignments queryObj = ParseQS.Decode("france=grenoble&germany=mannheim"); Assert.AreEqual(queryObj["france"], "grenoble"); Assert.AreEqual(queryObj["germany"], "mannheim"); // Assignments containing non-alphanumeric characters queryObj = ParseQS.Decode("india=new%20delhi"); Assert.AreEqual(queryObj["india"], "new delhi"); }
public Socket(Socket.Options options) { if (options.Host != null) { string[] strArray = options.Host.Split(':'); options.Hostname = strArray[0]; if (strArray.Length > 1) { options.Port = int.Parse(strArray[strArray.Length - 1]); } } this.Secure = options.Secure; this.Hostname = options.Hostname; this.Port = options.Port; this.Query = options.QueryString != null?ParseQS.Decode(options.QueryString) : new Dictionary <string, string>(); if (options.Query != null) { foreach (KeyValuePair <string, string> keyValuePair in options.Query) { this.Query.Add(keyValuePair.Key, keyValuePair.Value); } } this.Upgrade = options.Upgrade; this.Path = (options.Path ?? "/engine.io").Replace("/$", "") + "/"; this.TimestampParam = options.TimestampParam ?? "t"; this.TimestampRequests = options.TimestampRequests; this.Transports = options.Transports ?? ImmutableList <string> .Empty.Add(Polling.NAME).Add(WebSocket.NAME); this.PolicyPort = options.PolicyPort != 0 ? options.PolicyPort : 843; this.RememberUpgrade = options.RememberUpgrade; this.Cookies = options.Cookies; if (options.IgnoreServerCertificateValidation) { ServerCertificate.IgnoreServerCertificateValidation(); } this.ExtraHeaders = options.ExtraHeaders; }
public void Encode() { Dictionary <string, string> obj; obj = new Dictionary <string, string> { { "a", "b" } }; var imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.Equal("a=b", ParseQS.Encode(imObj)); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "d" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.Equal("a=b&c=d", ParseQS.Encode(imObj)); obj = new Dictionary <string, string> { { "a", "b" }, { "c", "tobi rocks" } }; imObj = ImmutableDictionary.Create <string, string>().AddRange(obj); Assert.Equal("a=b&c=tobi%20rocks", ParseQS.Encode(imObj)); }
public string Uri() { Dictionary <string, string> dictionary = new Dictionary <string, string>((IDictionary <string, string>) this.Query); string str1 = this.Secure ? "https" : "http"; string str2 = ""; if (this.TimestampRequests) { dictionary.Add(this.TimestampParam, DateTime.Now.Ticks.ToString() + "-" + (object)Transport.Timestamps++); } dictionary.Add("b64", "1"); string str3 = ParseQS.Encode(dictionary); if (this.Port > 0 && ("https" == str1 && this.Port != 443 || "http" == str1 && this.Port != 80)) { str2 = ":" + (object)this.Port; } if (str3.Length > 0) { str3 = "?" + str3; } return(str1 + "://" + this.Hostname + str2 + this.Path + str3); }
public Socket(Options options) { if (options.Host != null) { var pieces = options.Host.Split(':'); options.Hostname = pieces[0]; if (pieces.Length > 1) { options.Port = int.Parse(pieces[pieces.Length - 1]); } } Secure = options.Secure; Hostname = options.Hostname; Port = options.Port; Proxy = options.Proxy; Query = options.QueryString != null?ParseQS.Decode(options.QueryString) : new Dictionary <string, string>(); Upgrade = options.Upgrade; Path = (options.Path ?? "/engine.io").Replace("/$", "") + "/"; TimestampParam = (options.TimestampParam ?? "t"); TimestampRequests = options.TimestampRequests; var defaultTransport = new List <string>(); defaultTransport.Add(Polling.NAME); defaultTransport.Add(WebSocket.NAME); Transports = options.Transports ?? defaultTransport; PolicyPort = options.PolicyPort != 0 ? options.PolicyPort : 843; RememberUpgrade = options.RememberUpgrade; Cookies = options.Cookies; if (options.IgnoreServerCertificateValidation) { ServerCertificate.IgnoreServerCertificateValidation(); } }