예제 #1
0
 // make sure the connection is still open and from the same host
 public Connection GetConnnection(Uri uri, Uri proxy, Connection liveConnection)
 {
     if (liveConnection != null
         && liveConnection.IsConnected()
         && liveConnection.Uri.Host.ToLower() == uri.Host.ToLower())
     {
         return liveConnection;
     }
     else
     {
         liveConnection.Close();
         return GetConnectionPrivate(uri, proxy);
     }
 }
예제 #2
0
 private HttpResponse GetResponse(Connection connection)
 {
     HttpResponse response = connection.ReceiveResponseHeaders();
     _cookieStore.ReadCookiesFromResponse(response);
     connection.ReceiveResponseEntity(response);
     
     // for response code 100 we expect another http message to arrive later
     if (response.ResponseCode != 100)
     {
         connection.CheckKeepAlive(response);
     }
     return response;
 }
예제 #3
0
	    private HttpResponse SendRequestAndGetResponse(Connection connection, HttpRequest request)
        {
            _cookieStore.WriteCookiesToRequest(request);
            
            // if we need to send a body (not only headers)
            if (request.GetType().GetInterface("HttpEntityEnclosingRequest") != null)
            {
                var heer = (HttpEntityEnclosingRequest)request;
                connection.SendRequestHeaderAndEntity(request, heer.Entity, heer.ExpectContinue);
            }
            else
            {
                connection.SendRequestHeader(request);
            }

            return GetResponse(connection);
        }
예제 #4
0
	    private Connection InitiateConnection(Connection connection)
	    {
		    connection.IsBusy = true;
		    connection.Connect();
		    return connection;
	    }