예제 #1
0
        public HTTPSHostTest()
            : base(LogicOf <Nothing> .New((x) =>
        {
            var ep = EndPoint.NewFreeLocalEndPointSpecifyingPort(80);

            var host = HTTPSHost.New(ep,
                                     (req) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<HTML><BODY>");
                var lines = HTTPSHost.DumpHTTPRequest(req);
                foreach (var eachline in lines)
                {
                    sb.AppendLine(eachline + "<BR>");
                }
                sb.AppendLine("</BODY></HTML>");

                return(sb.ToString());
            }, "test/");

            using (host)
            {
                host.Initialize();
                host.Start();

                string uri = "https://" + ep.IPAddress + ":" + ep.Port;

                //Console.ReadLine();

                ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

                //using (WebClient webClient = new WebClient())
                //{
                //    var stream = webClient.OpenRead(uri);
                //    using (StreamReader sr = new StreamReader(stream))
                //    {
                //        var page = sr.ReadToEnd();
                //    }
                //}

                //now hit it with some requests
                using (var client = new HttpClient())
                {
                    var getdat = HTTPClient.Get(client, uri);
                    HTTPClient.Delete(client, uri);
                    var postdat = HTTPClient.Post(client, new StringContent("yo"), uri);
                    var putdat  = HTTPClient.Put(client, new StringContent("yo"), uri);
                }
            }
        }))
        {
        }
예제 #2
0
 public static HTTPSHost New(EndPoint ep, Func<HttpListenerRequest, string> method, string path)
 {
     HTTPSHost host = new HTTPSHost(ep, method, path);
     return host;
 }
예제 #3
0
        public static HTTPSHost New(EndPoint ep, Func <HttpListenerRequest, string> method, string path)
        {
            HTTPSHost host = new HTTPSHost(ep, method, path);

            return(host);
        }