internal virtual HttpClientConnection GetConnection() { CPoolEntry local = this.poolEntry; if (local == null) { return(null); } return(local.GetConnection()); }
/// <exception cref="System.IO.IOException"></exception> public virtual void Upgrade(HttpClientConnection managedConn, HttpRoute route, HttpContext context) { Args.NotNull(managedConn, "Managed Connection"); Args.NotNull(route, "HTTP route"); ManagedHttpClientConnection conn; lock (managedConn) { CPoolEntry entry = CPoolProxy.GetPoolEntry(managedConn); conn = entry.GetConnection(); } this.connectionOperator.Upgrade(conn, route.GetTargetHost(), context); }
public virtual void ReleaseConnection(HttpClientConnection managedConn, object state , long keepalive, TimeUnit tunit) { Args.NotNull(managedConn, "Managed connection"); lock (managedConn) { CPoolEntry entry = CPoolProxy.Detach(managedConn); if (entry == null) { return; } ManagedHttpClientConnection conn = entry.GetConnection(); try { if (conn.IsOpen()) { entry.SetState(state); entry.UpdateExpiry(keepalive, tunit != null ? tunit : TimeUnit.Milliseconds); if (this.log.IsDebugEnabled()) { string s; if (keepalive > 0) { s = "for " + (double)keepalive / 1000 + " seconds"; } else { s = "indefinitely"; } this.log.Debug("Connection " + Format(entry) + " can be kept alive " + s); } } } finally { this.pool.Release(entry, conn.IsOpen() && entry.IsRouteComplete()); if (this.log.IsDebugEnabled()) { this.log.Debug("Connection released: " + Format(entry) + FormatStats(entry.GetRoute ())); } } } }
/// <exception cref="System.IO.IOException"></exception> public virtual void Connect(HttpClientConnection managedConn, HttpRoute route, int connectTimeout, HttpContext context) { Args.NotNull(managedConn, "Managed Connection"); Args.NotNull(route, "HTTP route"); ManagedHttpClientConnection conn; lock (managedConn) { CPoolEntry entry = CPoolProxy.GetPoolEntry(managedConn); conn = entry.GetConnection(); } HttpHost host; if (route.GetProxyHost() != null) { host = route.GetProxyHost(); } else { host = route.GetTargetHost(); } IPEndPoint localAddress = route.GetLocalSocketAddress(); SocketConfig socketConfig = this.configData.GetSocketConfig(host); if (socketConfig == null) { socketConfig = this.configData.GetDefaultSocketConfig(); } if (socketConfig == null) { socketConfig = SocketConfig.Default; } this.connectionOperator.Connect(conn, host, localAddress, connectTimeout, socketConfig , context); }