Esempio n. 1
0
        private static void TestHttp(string host, string url, int port, SPWF04SxConnectionSecurityType security, bool get)
        {
            var buffer = new byte[512];
            var start  = DateTime.UtcNow;
            var code   = get ? wifi.SendHttpGet(host, url, port, security) : wifi.SendHttpPost(host, url, port, security);

            Debug.WriteLine($"HTTP {code}");

            var total = 0;

            while (wifi.ReadHttpResponse(buffer, 0, buffer.Length) is var read && read > 0)
            {
                total += read;

                try {
                    Debugger.Log(0, "", Encoding.UTF8.GetString(buffer, 0, read));
                }
                catch {
                    Debugger.Log(0, "", Encoding.UTF8.GetString(buffer, 0, read - 1));
                }

                Thread.Sleep(100);
            }

            Debug.WriteLine($"\r\nRead: {total:N0} in {(DateTime.UtcNow - start).TotalMilliseconds:N0}ms");
        }