Esempio n. 1
0
 public static SocketHttpResponse GetRequest(string url, string ipAddress)
 {
     using (SocketHttpDataProvider provider = new SocketHttpDataProvider(2))
         using (SocketReference socket = provider.Sockets.GetSocket(new IPEndPoint(IPAddress.Parse(ipAddress), 80)))
         {
             SocketHttpRequest request = (SocketHttpRequest)provider.GetRequest(new Uri(url));
             return((SocketHttpResponse)request.GetResponse(socket.Socket));
         }
 }
Esempio n. 2
0
        private void ProcessUri(Uri uri, SocketHttpResponse response)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            using (SocketReference socketReference = _socketFactory.GetSocket(uri))
            {
                watch.Stop();
                response.Timing.OpeningConnection = watch.Elapsed;
                ProcessUri(uri, response, socketReference.Socket.Stream);
                if (response.Headers.TryGetValue("Connection") == "close")
                {
                    socketReference.Socket.Socket.Close();
                }
            }
        }