Exemplo n.º 1
0
        public void SendRequest(CrawlerWebRequest request)
        {
            responseUri_ = request.requestUri_;

            request.header_ = request.methodName_ + " " + responseUri_.PathAndQuery + " HTTP/1.0\r\n" + request.headers_;
            socket_.Send(Encoding.ASCII.GetBytes(request.header_));
        }
Exemplo n.º 2
0
        public void Connect(CrawlerWebRequest request)
        {
            responseUri_ = request.requestUri_;

            socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint remoteEP = new IPEndPoint(Dns.GetHostEntry(responseUri_.Host).AddressList[0], responseUri_.Port);

            socket_.Connect(remoteEP);
        }
 public static CrawlerWebRequest Create(Uri uri, CrawlerWebRequest 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 CrawlerWebRequest(uri, bKeepAlive));
 }