com.crashlytics.tools.android_2.1.0

t socket = super.getSocket();
    if ((socket instanceof SSLSocket)) {
      return ((SSLSocket)socket).getSession();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.DefaultManagedHttpClientConnection
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class DefaultProxyRoutePlanner
  extends DefaultRoutePlanner
{
  private final HttpHost proxy;
  
  public DefaultProxyRoutePlanner(HttpHost proxy, SchemePortResolver schemePortResolver)
  {
    super(schemePortResolver);
    this.proxy = ((HttpHost)Args.notNull(proxy, "Proxy host"));
  }
  
  public DefaultProxyRoutePlanner(HttpHost proxy)
  {
    this(proxy, null);
  }
  
  protected HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context)
    throws HttpException
  {
    return proxy;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.DefaultProxyRoutePlanner
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;
import org.apache.http.HttpMessage;
import org.apache.http.HttpResponseFactory;
import org.apache.http.NoHttpResponseException;
import org.apache.http.ProtocolException;
import org.apache.http.StatusLine;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.impl.io.AbstractMessageParser;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.message.LineParser;
import org.apache.http.message.ParserCursor;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;
import org.apache.http.util.CharArrayBuffer;

@Deprecated
@ThreadSafe
public class DefaultResponseParser
  extends AbstractMessageParser<HttpMessage>
{
  private final Log log = LogFactory.getLog(getClass());
  private final HttpResponseFactory responseFactory;
  private final CharArrayBuffer lineBuf;
  private final int maxGarbageLines;
  
  public DefaultResponseParser(SessionInputBuffer buffer, LineParser parser, HttpResponseFactory responseFactory, HttpParams params)
  {
    super(buffer, parser, params);
    Args.notNull(responseFactory, "Response factory");
    this.responseFactory = responseFactory;
    lineBuf = new CharArrayBuffer(128);
    maxGarbageLines = getMaxGarbageLines(params);
  }
  
  protected int getMaxGarbageLines(HttpParams params)
  {
    return params.getIntParameter("http.connection.max-status-line-garbage", Integer.MAX_VALUE);
  }
  
  protected HttpMessage parseHead(SessionInputBuffer sessionBuffer)
    throws IOException, HttpException
  {
    int count = 0;
    ParserCursor cursor = null;
    for (;;)
    {
      lineBuf.clear();
      int i = sessionBuffer.readLine(lineBuf);
      if ((i == -1) && (count == 0)) {
        throw new NoHttpResponseException("The target server failed to respond");
      }
      cursor = new ParserCursor(0, lineBuf.length());
      if (lineParser.hasProtocolVersion(lineBuf, cursor)) {
        break;
      }
      if ((i == -1) || (count >= maxGarbageLines)) {
        throw new ProtocolException("The server failed to respond with a valid HTTP response");
      }
      if (log.isDebugEnabled()) {
        log.debug("Garbage in response: " + lineBuf.toString());
      }
      count++;
    }
    StatusLine statusline = lineParser.parseStatusLine(lineBuf, cursor);
    return responseFactory.newHttpResponse(statusline, null);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.DefaultResponseParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.net.InetAddress;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class DefaultRoutePlanner
  implements HttpRoutePlanner
{
  private final SchemePortResolver schemePortResolver;
  
  public DefaultRoutePlanner(SchemePortResolver schemePortResolver)
  {
    this.schemePortResolver = (schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE);
  }
  
  public HttpRoute determineRoute(HttpHost host, HttpRequest request, HttpContext context)
    throws HttpException
  {
    Args.notNull(host, "Target host");
    Args.notNull(request, "Request");
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    RequestConfig config = clientContext.getRequestConfig();
    InetAddress local = config.getLocalAddress();
    HttpHost proxy = config.getProxy();
    if (proxy == null) {
      proxy = determineProxy(host, request, context);
    }
    HttpHost target;
    if (host.getPort() <= 0) {
      try
      {
        target = new HttpHost(host.getHostName(), schemePortResolver.resolve(host), host.getSchemeName());
      }
      catch (UnsupportedSchemeException ex)
      {
        throw new HttpException(ex.getMessage());
      }
    } else {
      target = host;
    }
    boolean secure = target.getSchemeName().equalsIgnoreCase("https");
    if (proxy == null) {
      return new HttpRoute(target, local, secure);
    }
    return new HttpRoute(target, local, proxy, secure);
  }
  
  protected HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context)
    throws HttpException
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.DefaultRoutePlanner
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.util.Args;

@Immutable
public class DefaultSchemePortResolver
  implements SchemePortResolver
{
  public static final DefaultSchemePortResolver INSTANCE = new DefaultSchemePortResolver();
  
  public int resolve(HttpHost host)
    throws UnsupportedSchemeException
  {
    Args.notNull(host, "HTTP host");
    int port = host.getPort();
    if (port > 0) {
      return port;
    }
    String name = host.getSchemeName();
    if (name.equalsIgnoreCase("http")) {
      return 80;
    }
    if (name.equalsIgnoreCase("https")) {
      return 443;
    }
    throw new UnsupportedSchemeException(name + " protocol is not supported");
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.DefaultSchemePortResolver
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Lookup;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
class HttpClientConnectionOperator
{
  static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
  private final Log log = LogFactory.getLog(HttpClientConnectionManager.class);
  private final Lookup<ConnectionSocketFactory> socketFactoryRegistry;
  private final SchemePortResolver schemePortResolver;
  private final DnsResolver dnsResolver;
  
  HttpClientConnectionOperator(Lookup<ConnectionSocketFactory> socketFactoryRegistry, SchemePortResolver schemePortResolver, DnsResolver dnsResolver)
  {
    Args.notNull(socketFactoryRegistry, "Socket factory registry");
    this.socketFactoryRegistry = socketFactoryRegistry;
    this.schemePortResolver = (schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE);
    
    this.dnsResolver = (dnsResolver != null ? dnsResolver : SystemDefaultDnsResolver.INSTANCE);
  }
  
  private Lookup<ConnectionSocketFactory> getSocketFactoryRegistry(HttpContext context)
  {
    Lookup<ConnectionSocketFactory> reg = (Lookup)context.getAttribute("http.socket-factory-registry");
    if (reg == null) {
      reg = socketFactoryRegistry;
    }
    return reg;
  }
  
  public void connect(ManagedHttpClientConnection conn, HttpHost host, InetSocketAddress localAddress, int connectTimeout, SocketConfig socketConfig, HttpContext context)
    throws IOException
  {
    Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context);
    ConnectionSocketFactory sf = (ConnectionSocketFactory)registry.lookup(host.getSchemeName());
    if (sf == null) {
      throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported");
    }
    InetAddress[] addresses = dnsResolver.resolve(host.getHostName());
    int port = schemePortResolver.resolve(host);
    for (int i = 0; i < addresses.length; i++)
    {
      InetAddress address = addresses[i];
      boolean last = i == addresses.length - 1;
      
      Socket sock = sf.createSocket(context);
      sock.setReuseAddress(socketConfig.isSoReuseAddress());
      conn.bind(sock);
      
      InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
      if (log.isDebugEnabled()) {
        log.debug("Connecting to " + remoteAddress);
      }
      try
      {
        sock.setSoTimeout(socketConfig.getSoTimeout());
        sock = sf.connectSocket(connectTimeout, sock, host, remoteAddress, localAddress, context);
        
        sock.setTcpNoDelay(socketConfig.isTcpNoDelay());
        sock.setKeepAlive(socketConfig.isSoKeepAlive());
        int linger = socketConfig.getSoLinger();
        if (linger >= 0) {
          sock.setSoLinger(linger > 0, linger);
        }
        conn.bind(sock);
        return;
      }
      catch (SocketTimeoutException ex)
      {
        if (last) {
          throw new ConnectTimeoutException(ex, host, addresses);
        }
      }
      catch (ConnectException ex)
      {
        if (last)
        {
          String msg = ex.getMessage();
          if ("Connection timed out".equals(msg)) {
            throw new ConnectTimeoutException(ex, host, addresses);
          }
          throw new HttpHostConnectException(ex, host, addresses);
        }
      }
      if (log.isDebugEnabled()) {
        log.debug("Connect to " + remoteAddress + " timed out. " + "Connection will be retried using another IP address");
      }
    }
  }
  
  public void upgrade(ManagedHttpClientConnection conn, HttpHost host, HttpContext context)
    throws IOException
  {
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
    ConnectionSocketFactory sf = (ConnectionSocketFactory)registry.lookup(host.getSchemeName());
    if (sf == null) {
      throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported");
    }
    if (!(sf instanceof LayeredConnectionSocketFactory)) {
      throw new UnsupportedSchemeException(host.getSchemeName() + " protocol does not support connection upgrade");
    }
    LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory)sf;
    Socket sock = conn.getSocket();
    int port = schemePortResolver.resolve(host);
    sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
    conn.bind(sock);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.HttpClientConnectionOperator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import org.apache.http.conn.ClientConnectionOperator;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.pool.ConnFactory;

class HttpConnPool$InternalConnFactory
  implements ConnFactory<HttpRoute, OperatedClientConnection>
{
  private final ClientConnectionOperator connOperator;
  
  HttpConnPool$InternalConnFactory(ClientConnectionOperator connOperator)
  {
    this.connOperator = connOperator;
  }
  
  public OperatedClientConnection create(HttpRoute route)
    throws IOException
  {
    return connOperator.createConnection();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.HttpConnPool.InternalConnFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.http.conn.ClientConnectionOperator;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.pool.AbstractConnPool;
import org.apache.http.pool.ConnFactory;

@Deprecated
class HttpConnPool
  extends AbstractConnPool<HttpRoute, OperatedClientConnection, HttpPoolEntry>
{
  private static final AtomicLong COUNTER = new AtomicLong();
  private final Log log;
  private final long timeToLive;
  private final TimeUnit tunit;
  
  public HttpConnPool(Log log, ClientConnectionOperator connOperator, int defaultMaxPerRoute, int maxTotal, long timeToLive, TimeUnit tunit)
  {
    super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal);
    this.log = log;
    this.timeToLive = timeToLive;
    this.tunit = tunit;
  }
  
  protected HttpPoolEntry createEntry(HttpRoute route, OperatedClientConnection conn)
  {
    String id = Long.toString(COUNTER.getAndIncrement());
    return new HttpPoolEntry(log, id, route, conn, timeToLive, tunit);
  }
  
  static class InternalConnFactory
    implements ConnFactory<HttpRoute, OperatedClientConnection>
  {
    private final ClientConnectionOperator connOperator;
    
    InternalConnFactory(ClientConnectionOperator connOperator)
    {
      this.connOperator = connOperator;
    }
    
    public OperatedClientConnection create(HttpRoute route)
      throws IOException
    {
      return connOperator.createConnection();
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.HttpConnPool
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteTracker;
import org.apache.http.pool.PoolEntry;

@Deprecated
class HttpPoolEntry
  extends PoolEntry<HttpRoute, OperatedClientConnection>
{
  private final Log log;
  private final RouteTracker tracker;
  
  public HttpPoolEntry(Log log, String id, HttpRoute route, OperatedClientConnection conn, long timeToLive, TimeUnit tunit)
  {
    super(id, route, conn, timeToLive, tunit);
    this.log = log;
    tracker = new RouteTracker(route);
  }
  
  public boolean isExpired(long now)
  {
    boolean expired = super.isExpired(now);
    if ((expired) && (log.isDebugEnabled())) {
      log.debug("Connection " + this + " expired @ " + new Date(getExpiry()));
    }
    return expired;
  }
  
  RouteTracker getTracker()
  {
    return tracker;
  }
  
  HttpRoute getPlannedRoute()
  {
    return (HttpRoute)getRoute();
  }
  
  HttpRoute getEffectiveRoute()
  {
    return tracker.toRoute();
  }
  
  public boolean isClosed()
  {
    OperatedClientConnection conn = (OperatedClientConnection)getConnection();
    return !conn.isOpen();
  }
  
  public void close()
  {
    OperatedClientConnection conn = (OperatedClientConnection)getConnection();
    try
    {
      conn.close();
    }
    catch (IOException ex)
    {
      log.debug("I/O error closing connection", ex);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.HttpPoolEntry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.util.concurrent.TimeUnit;

class IdleConnectionHandler$TimeValues
{
  private final long timeAdded;
  private final long timeExpires;
  
  IdleConnectionHandler$TimeValues(long now, long validDuration, TimeUnit validUnit)
  {
    timeAdded = now;
    if (validDuration > 0L) {
      timeExpires = (now + validUnit.toMillis(validDuration));
    } else {
      timeExpires = Long.MAX_VALUE;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.IdleConnectionHandler.TimeValues
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpConnection;

@Deprecated
public class IdleConnectionHandler
{
  private final Log log = LogFactory.getLog(getClass());
  private final Map<HttpConnection, TimeValues> connectionToTimes;
  
  public IdleConnectionHandler()
  {
    connectionToTimes = new HashMap();
  }
  
  public void add(HttpConnection connection, long validDuration, TimeUnit unit)
  {
    long timeAdded = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
      log.debug("Adding connection at: " + timeAdded);
    }
    connectionToTimes.put(connection, new TimeValues(timeAdded, validDuration, unit));
  }
  
  public boolean remove(HttpConnection connection)
  {
    TimeValues times = (TimeValues)connectionToTimes.remove(connection);
    if (times == null)
    {
      log.warn("Removing a connection that never existed!");
      return true;
    }
    return System.currentTimeMillis() <= timeExpires;
  }
  
  public void removeAll()
  {
    connectionToTimes.clear();
  }
  
  public void closeIdleConnections(long idleTime)
  {
    long idleTimeout = System.currentTimeMillis() - idleTime;
    if (log.isDebugEnabled()) {
      log.debug("Checking for connections, idle timeout: " + idleTimeout);
    }
    for (Map.Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet())
    {
      HttpConnection conn = (HttpConnection)entry.getKey();
      TimeValues times = (TimeValues)entry.getValue();
      long connectionTime = timeAdded;
      if (connectionTime <= idleTimeout)
      {
        if (log.isDebugEnabled()) {
          log.debug("Closing idle connection, connection time: " + connectionTime);
        }
        try
        {
          conn.close();
        }
        catch (IOException ex)
        {
          log.debug("I/O error closing connection", ex);
        }
      }
    }
  }
  
  public void closeExpiredConnections()
  {
    long now = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
      log.debug("Checking for expired connections, now: " + now);
    }
    for (Map.Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet())
    {
      HttpConnection conn = (HttpConnection)entry.getKey();
      TimeValues times = (TimeValues)entry.getValue();
      if (timeExpires <= now)
      {
        if (log.isDebugEnabled()) {
          log.debug("Closing connection, expired @: " + timeExpires);
        }
        try
        {
          conn.close();
        }
        catch (IOException ex)
        {
          log.debug("I/O error closing connection", ex);
        }
      }
    }
  }
  
  private static class TimeValues
  {
    private final long timeAdded;
    private final long timeExpires;
    
    TimeValues(long now, long validDuration, TimeUnit validUnit)
    {
      timeAdded = now;
      if (validDuration > 0L) {
        timeExpires = (now + validUnit.toMillis(validDuration));
      } else {
        timeExpires = Long.MAX_VALUE;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.IdleConnectionHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.conn.DnsResolver;
import org.apache.http.util.Args;

public class InMemoryDnsResolver
  implements DnsResolver
{
  private final Log log = LogFactory.getLog(InMemoryDnsResolver.class);
  private final Map<String, InetAddress[]> dnsMap;
  
  public InMemoryDnsResolver()
  {
    dnsMap = new ConcurrentHashMap();
  }
  
  public void add(String host, InetAddress... ips)
  {
    Args.notNull(host, "Host name");
    Args.notNull(ips, "Array of IP addresses");
    dnsMap.put(host, ips);
  }
  
  public InetAddress[] resolve(String host)
    throws UnknownHostException
  {
    InetAddress[] resolvedAddresses = (InetAddress[])dnsMap.get(host);
    if (log.isInfoEnabled()) {
      log.info("Resolving " + host + " to " + Arrays.deepToString(resolvedAddresses));
    }
    if (resolvedAddresses == null) {
      throw new UnknownHostException(host + " cannot be resolved");
    }
    return resolvedAddresses;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.InMemoryDnsResolver
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.io.InputStream;
import org.apache.http.annotation.NotThreadSafe;

@NotThreadSafe
class LoggingInputStream
  extends InputStream
{
  private final InputStream in;
  private final Wire wire;
  
  public LoggingInputStream(InputStream in, Wire wire)
  {
    this.in = in;
    this.wire = wire;
  }
  
  public int read()
    throws IOException
  {
    int b = in.read();
    if (b != -1) {
      wire.input(b);
    }
    return b;
  }
  
  public int read(byte[] b)
    throws IOException
  {
    int bytesRead = in.read(b);
    if (bytesRead != -1) {
      wire.input(b, 0, bytesRead);
    }
    return bytesRead;
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    int bytesRead = in.read(b, off, len);
    if (bytesRead != -1) {
      wire.input(b, off, bytesRead);
    }
    return bytesRead;
  }
  
  public long skip(long n)
    throws IOException
  {
    return super.skip(n);
  }
  
  public int available()
    throws IOException
  {
    return in.available();
  }
  
  public synchronized void mark(int readlimit)
  {
    super.mark(readlimit);
  }
  
  public synchronized void reset()
    throws IOException
  {
    super.reset();
  }
  
  public boolean markSupported()
  {
    return false;
  }
  
  public void close()
    throws IOException
  {
    in.close();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.LoggingInputStream
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import org.apache.commons.logging.Log;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.config.MessageConstraints;
import org.apache.http.entity.ContentLengthStrategy;
import org.apache.http.io.HttpMessageParserFactory;
import org.apache.http.io.HttpMessageWriterFactory;

@NotThreadSafe
class LoggingManagedHttpClientConnection
  extends DefaultManagedHttpClientConnection
{
  private final Log log;
  private final Log headerlog;
  private final Wire wire;
  
  public LoggingManagedHttpClientConnection(String id, Log log, Log headerlog, Log wirelog, int buffersize, int fragmentSizeHint, CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, HttpMessageWriterFactory<HttpRequest> requestWriterFactory, HttpMessageParserFactory<HttpResponse> responseParserFactory)
  {
    super(id, buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy, outgoingContentStrategy, requestWriterFactory, responseParserFactory);
    
    this.log = log;
    this.headerlog = headerlog;
    wire = new Wire(wirelog, id);
  }
  
  public void close()
    throws IOException
  {
    if (log.isDebugEnabled()) {
      log.debug(getId() + ": Close connection");
    }
    super.close();
  }
  
  public void shutdown()
    throws IOException
  {
    if (log.isDebugEnabled()) {
      log.debug(getId() + ": Shutdown connection");
    }
    super.shutdown();
  }
  
  protected InputStream getSocketInputStream(Socket socket)
    throws IOException
  {
    InputStream in = super.getSocketInputStream(socket);
    if (wire.enabled()) {
      in = new LoggingInputStream(in, wire);
    }
    return in;
  }
  
  protected OutputStream getSocketOutputStream(Socket socket)
    throws IOException
  {
    OutputStream out = super.getSocketOutputStream(socket);
    if (wire.enabled()) {
      out = new LoggingOutputStream(out, wire);
    }
    return out;
  }
  
  protected void onResponseReceived(HttpResponse response)
  {
    if ((response != null) && (headerlog.isDebugEnabled()))
    {
      headerlog.debug(getId() + " << " + response.getStatusLine().toString());
      Header[] headers = response.getAllHeaders();
      for (Header header : headers) {
        headerlog.debug(getId() + " << " + header.toString());
      }
    }
  }
  
  protected void onRequestSubmitted(HttpRequest request)
  {
    if ((request != null) && (headerlog.isDebugEnabled()))
    {
      headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
      Header[] headers = request.getAllHeaders();
      for (Header header : headers) {
        headerlog.debug(getId() + " >> " + header.toString());
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.LoggingManagedHttpClientConnection
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.io.OutputStream;
import org.apache.http.annotation.NotThreadSafe;

@NotThreadSafe
class LoggingOutputStream
  extends OutputStream
{
  private final OutputStream out;
  private final Wire wire;
  
  public LoggingOutputStream(OutputStream out, Wire wire)
  {
    this.out = out;
    this.wire = wire;
  }
  
  public void write(int b)
    throws IOException
  {
    wire.output(b);
  }
  
  public void write(byte[] b)
    throws IOException
  {
    wire.output(b);
    out.write(b);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    wire.output(b, off, len);
    out.write(b, off, len);
  }
  
  public void flush()
    throws IOException
  {
    out.flush();
  }
  
  public void close()
    throws IOException
  {
    out.close();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.LoggingOutputStream
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.http.Consts;
import org.apache.http.annotation.Immutable;
import org.apache.http.io.EofSensor;
import org.apache.http.io.HttpTransportMetrics;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.util.CharArrayBuffer;

@Deprecated
@Immutable
public class LoggingSessionInputBuffer
  implements SessionInputBuffer, EofSensor
{
  private final SessionInputBuffer in;
  private final EofSensor eofSensor;
  private final Wire wire;
  private final String charset;
  
  public LoggingSessionInputBuffer(SessionInputBuffer in, Wire wire, String charset)
  {
    this.in = in;
    eofSensor = ((in instanceof EofSensor) ? (EofSensor)in : null);
    this.wire = wire;
    this.charset = (charset != null ? charset : Consts.ASCII.name());
  }
  
  public LoggingSessionInputBuffer(SessionInputBuffer in, Wire wire)
  {
    this(in, wire, null);
  }
  
  public boolean isDataAvailable(int timeout)
    throws IOException
  {
    return in.isDataAvailable(timeout);
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    int l = in.read(b, off, len);
    if ((wire.enabled()) && (l > 0)) {
      wire.input(b, off, l);
    }
    return l;
  }
  
  public int read()
    throws IOException
  {
    int l = in.read();
    if ((wire.enabled()) && (l != -1)) {
      wire.input(l);
    }
    return l;
  }
  
  public int read(byte[] b)
    throws IOException
  {
    int l = in.read(b);
    if ((wire.enabled()) && (l > 0)) {
      wire.input(b, 0, l);
    }
    return l;
  }
  
  public String readLine()
    throws IOException
  {
    String s = in.readLine();
    if ((wire.enabled()) && (s != null))
    {
      String tmp = s + "\r\n";
      wire.input(tmp.getBytes(charset));
    }
    return s;
  }
  
  public int readLine(CharArrayBuffer buffer)
    throws IOException
  {
    int l = in.readLine(buffer);
    if ((wire.enabled()) && (l >= 0))
    {
      int pos = buffer.length() - l;
      String s = new String(buffer.buffer(), pos, l);
      String tmp = s + "\r\n";
      wire.input(tmp.getBytes(charset));
    }
    return l;
  }
  
  public HttpTransportMetrics getMetrics()
  {
    return in.getMetrics();
  }
  
  public boolean isEof()
  {
    if (eofSensor != null) {
      return eofSensor.isEof();
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.LoggingSessionInputBuffer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.http.Consts;
import org.apache.http.annotation.Immutable;
import org.apache.http.io.HttpTransportMetrics;
import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.util.CharArrayBuffer;

@Deprecated
@Immutable
public class LoggingSessionOutputBuffer
  implements SessionOutputBuffer
{
  private final SessionOutputBuffer out;
  private final Wire wire;
  private final String charset;
  
  public LoggingSessionOutputBuffer(SessionOutputBuffer out, Wire wire, String charset)
  {
    this.out = out;
    this.wire = wire;
    this.charset = (charset != null ? charset : Consts.ASCII.name());
  }
  
  public LoggingSessionOutputBuffer(SessionOutputBuffer out, Wire wire)
  {
    this(out, wire, null);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    out.write(b, off, len);
    if (wire.enabled()) {
      wire.output(b, off, len);
    }
  }
  
  public void write(int b)
    throws IOException
  {
    out.write(b);
    if (wire.enabled()) {
      wire.output(b);
    }
  }
  
  public void write(byte[] b)
    throws IOException
  {
    out.write(b);
    if (wire.enabled()) {
      wire.output(b);
    }
  }
  
  public void flush()
    throws IOException
  {
    out.flush();
  }
  
  public void writeLine(CharArrayBuffer buffer)
    throws IOException
  {
    out.writeLine(buffer);
    if (wire.enabled())
    {
      String s = new String(buffer.buffer(), 0, buffer.length());
      String tmp = s + "\r\n";
      wire.output(tmp.getBytes(charset));
    }
  }
  
  public void writeLine(String s)
    throws IOException
  {
    out.writeLine(s);
    if (wire.enabled())
    {
      String tmp = s + "\r\n";
      wire.output(tmp.getBytes(charset));
    }
  }
  
  public HttpTransportMetrics getMetrics()
  {
    return out.getMetrics();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.conn.LoggingSessionOutputBuffer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl.conn;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.apache.http.HttpConnectionMetrics;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionOperator;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteTracker;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;

@Deprecated
@NotThreadSafe
class ManagedClientConnectionImpl
  implements ManagedClientConnection
{
  private final ClientConnectionManager manager;
  private final ClientConnectionOperator operator;
  private volatile HttpPoolEntry poolEntry;
  private volatile boolean reusable;
  private volatile long duration;
  
  ManagedClientConnectionImpl(ClientConnectionManager manager, ClientConnectionOperator operator, HttpPoolEntry entry)
  {
    Args.notNull(manager, "Connection manager");
    Args.notNull(operator, "Connection operator");
    Args.notNull(entry, "HTTP pool entry");
    this.manager = manager;
    this.operator = operator;
    poolEntry = entry;
    reusable = false;
    duration = Long.MAX_VALUE;
  }
  
  public String getId()
  {
    return null;
  }
  
  HttpPoolEntry getPoolEntry()
  {
    return poolEntry;
  }
  
  HttpPoolEntry detach()
  {
    HttpPoolEntry local = poolEntry;
    poolEntry = null;
    return local;
  }
  
  public ClientConnectionManager getManager()
  {
    return manager;
  }
  
  private OperatedClientConnection getConnection()
  {
    HttpPoolEntry local = poolEntry;
    if (local == null) {
      return null;
    }
    return (OperatedClientConnection)local.getConnection();
  }
  
  private OperatedClientConnection ensureConnection()
  {
    HttpPoolEntry local = poolEntry;
    if (local == null) {
      throw new ConnectionShutdownException();
    }
    return (OperatedClientConnection)local.getConnection();
  }
  
  private HttpPoolEntry ensurePoolEntry()
  {
    HttpPoolEntry local = poolEntry;
    if (local == null) {
      throw new ConnectionShutdownException();
    }
    return local;
  }
  
  public void close()
    throws IOException
  {
    HttpPoolEntry local = poolEntry;
    if (local != null)
    {
      OperatedClientConnection conn = (OperatedClientConnection)local.getConnection();
      local.getTracker().reset();
      conn.close();
    }
  }
  
  public void shutdown()
    throws IOException
  {
    HttpPoolEntry local = poolEntry;
    if (local != null)
    {
      OperatedClientConnection conn = (OperatedClientConnection)local.getConnection();
      local.getTracker().reset();
      conn.shutdown();
    }
  }
  
  public boolean isOpen()
  {
    OperatedClientConnection conn = getConnection();
    if (conn != null) {
      return conn.isOpen();
    }
    return false;
  }
  
  public boolean isStale()
  {
    OperatedClientConnection conn = getConnection();
    if (conn != null) {
      return conn.isStale();
    }
    return true;
  }
  
  public void setSocketTimeout(int timeout)
  {
    OperatedClientConnection conn = ensureConnection();
    conn.setSocketTimeout(timeout);
  }
  
  public int getSocketTimeout()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getSocketTimeout();
  }
  
  public HttpConnectionMetrics getMetrics()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getMetrics();
  }
  
  public void flush()
    throws IOException
  {
    OperatedClientConnection conn = ensureConnection();
    conn.flush();
  }
  
  public boolean isResponseAvailable(int timeout)
    throws IOException
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.isResponseAvailable(timeout);
  }
  
  public void receiveResponseEntity(HttpResponse response)
    throws HttpException, IOException
  {
    OperatedClientConnection conn = ensureConnection();
    conn.receiveResponseEntity(response);
  }
  
  public HttpResponse receiveResponseHeader()
    throws HttpException, IOException
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.receiveResponseHeader();
  }
  
  public void sendRequestEntity(HttpEntityEnclosingRequest request)
    throws HttpException, IOException
  {
    OperatedClientConnection conn = ensureConnection();
    conn.sendRequestEntity(request);
  }
  
  public void sendRequestHeader(HttpRequest request)
    throws HttpException, IOException
  {
    OperatedClientConnection conn = ensureConnection();
    conn.sendRequestHeader(request);
  }
  
  public InetAddress getLocalAddress()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getLocalAddress();
  }
  
  public int getLocalPort()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getLocalPort();
  }
  
  public InetAddress getRemoteAddress()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getRemoteAddress();
  }
  
  public int getRemotePort()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getRemotePort();
  }
  
  public boolean isSecure()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.isSecure();
  }
  
  public void bind(Socket socket)
    throws IOException
  {
    throw new UnsupportedOperationException();
  }
  
  public Socket getSocket()
  {
    OperatedClientConnection conn = ensureConnection();
    return conn.getSocket();
  }
  
  public SSLSession getSSLSession()
  {
    OperatedClientConnection conn = ensureConnection();
    SSLSession result = null;
    Socket sock = conn.getSocket();
    if ((sock instanceof SSLSocket)) {
      result = ((SSLSocket)sock).getSession();
    }
    return result;
  }
  
  public Object getAttribute(String id)
  {
    OperatedClientConnection conn = ensureConnection();
    if ((conn instanceof HttpContext)) {
      return ((HttpContext)conn).getAttribute(id);
    }
    return null;
  }
  
  public Object removeAttribute(String id)
  {
    OperatedClientConnection conn = ensureConnection();
    if ((conn instanceof HttpContext)) {
      return ((HttpContext)conn).removeAttribute(id);
    }
    return null;
  }
  
  public void setAttribute(String id, Object obj)
  {
    OperatedClientConnection conn = ensureConnection();
    if ((conn instanceof HttpContext)) {
      ((HttpContext)conn).setAttrib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd