Example #1
0
 public static MyWebRequest Create(Uri uri, MyWebRequest AliveRequest, bool bKeepAlive)
 {
     if (bKeepAlive &&
         AliveRequest != null &&
         AliveRequest.response != null &&
         AliveRequest.response.KeepAlive &&
         AliveRequest.response.socket.Connected &&
         AliveRequest.RequestUri.Host == uri.Host)
     {
         AliveRequest.RequestUri = uri;
         return AliveRequest;
     }
     return new MyWebRequest(uri, bKeepAlive);
 }
Example #2
0
        public void SendRequest(MyWebRequest request)
        {
            ResponseUri = request.RequestUri;

            request.Header = request.Method + " " + ResponseUri.PathAndQuery + " HTTP/1.0\r\n" + request.Headers;
            socket.Send(Encoding.ASCII.GetBytes(request.Header));
        }
Example #3
0
        public void Connect(MyWebRequest request)
        {
            ResponseUri = request.RequestUri;

            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint remoteEP = new IPEndPoint(Dns.Resolve(ResponseUri.Host).AddressList[0], ResponseUri.Port);
            socket.Connect(remoteEP);
        }