// 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); } }
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; }
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); }
private Connection InitiateConnection(Connection connection) { connection.IsBusy = true; connection.Connect(); return connection; }