com.crashlytics.tools.android_2.1.0

nding: ");
    buffer.append(pending);
    buffer.append("; available: ");
    buffer.append(available);
    buffer.append("; max: ");
    buffer.append(max);
    buffer.append("]");
    return buffer.toString();
  }
}

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

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;

@NotThreadSafe
abstract class RouteSpecificPool<T, C, E extends PoolEntry<T, C>>
{
  private final T route;
  private final Set<E> leased;
  private final LinkedList<E> available;
  private final LinkedList<PoolEntryFuture<E>> pending;
  
  RouteSpecificPool(T route)
  {
    this.route = route;
    leased = new HashSet();
    available = new LinkedList();
    pending = new LinkedList();
  }
  
  protected abstract E createEntry(C paramC);
  
  public final T getRoute()
  {
    return (T)route;
  }
  
  public int getLeasedCount()
  {
    return leased.size();
  }
  
  public int getPendingCount()
  {
    return pending.size();
  }
  
  public int getAvailableCount()
  {
    return available.size();
  }
  
  public int getAllocatedCount()
  {
    return available.size() + leased.size();
  }
  
  public E getFree(Object state)
  {
    if (!available.isEmpty())
    {
      if (state != null)
      {
        Iterator<E> it = available.iterator();
        while (it.hasNext())
        {
          E entry = (PoolEntry)it.next();
          if (state.equals(entry.getState()))
          {
            it.remove();
            leased.add(entry);
            return entry;
          }
        }
      }
      Iterator<E> it = available.iterator();
      while (it.hasNext())
      {
        E entry = (PoolEntry)it.next();
        if (entry.getState() == null)
        {
          it.remove();
          leased.add(entry);
          return entry;
        }
      }
    }
    return null;
  }
  
  public E getLastUsed()
  {
    if (!available.isEmpty()) {
      return (PoolEntry)available.getLast();
    }
    return null;
  }
  
  public boolean remove(E entry)
  {
    Args.notNull(entry, "Pool entry");
    if ((!available.remove(entry)) && 
      (!leased.remove(entry))) {
      return false;
    }
    return true;
  }
  
  public void free(E entry, boolean reusable)
  {
    Args.notNull(entry, "Pool entry");
    boolean found = leased.remove(entry);
    Asserts.check(found, "Entry %s has not been leased from this pool", new Object[] { entry });
    if (reusable) {
      available.addFirst(entry);
    }
  }
  
  public E add(C conn)
  {
    E entry = createEntry(conn);
    leased.add(entry);
    return entry;
  }
  
  public void queue(PoolEntryFuture<E> future)
  {
    if (future == null) {
      return;
    }
    pending.add(future);
  }
  
  public PoolEntryFuture<E> nextPending()
  {
    return (PoolEntryFuture)pending.poll();
  }
  
  public void unqueue(PoolEntryFuture<E> future)
  {
    if (future == null) {
      return;
    }
    pending.remove(future);
  }
  
  public void shutdown()
  {
    for (PoolEntryFuture<E> future : pending) {
      future.cancel(true);
    }
    pending.clear();
    for (E entry : available) {
      entry.close();
    }
    available.clear();
    for (E entry : leased) {
      entry.close();
    }
    leased.clear();
  }
  
  public String toString()
  {
    StringBuilder buffer = new StringBuilder();
    buffer.append("[route: ");
    buffer.append(route);
    buffer.append("][leased: ");
    buffer.append(leased.size());
    buffer.append("][available: ");
    buffer.append(available.size());
    buffer.append("][pending: ");
    buffer.append(pending.size());
    buffer.append("]");
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.pool.RouteSpecificPool
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.protocol;

import java.util.HashMap;
import java.util.Map;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@NotThreadSafe
public class BasicHttpContext
  implements HttpContext
{
  private final HttpContext parentContext;
  private Map<String, Object> map = null;
  
  public BasicHttpContext()
  {
    this(null);
  }
  
  public BasicHttpContext(HttpContext parentContext)
  {
    this.parentContext = parentContext;
  }
  
  public Object getAttribute(String id)
  {
    Args.notNull(id, "Id");
    Object obj = null;
    if (map != null) {
      obj = map.get(id);
    }
    if ((obj == null) && (parentContext != null)) {
      obj = parentContext.getAttribute(id);
    }
    return obj;
  }
  
  public void setAttribute(String id, Object obj)
  {
    Args.notNull(id, "Id");
    if (map == null) {
      map = new HashMap();
    }
    map.put(id, obj);
  }
  
  public Object removeAttribute(String id)
  {
    Args.notNull(id, "Id");
    if (map != null) {
      return map.remove(id);
    }
    return null;
  }
  
  public void clear()
  {
    if (map != null) {
      map.clear();
    }
  }
  
  public String toString()
  {
    if (map != null) {
      return map.toString();
    }
    return "{}";
  }
}

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

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@Deprecated
@NotThreadSafe
public final class BasicHttpProcessor
  implements HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList, Cloneable
{
  protected final List<HttpRequestInterceptor> requestInterceptors = new ArrayList();
  protected final List<HttpResponseInterceptor> responseInterceptors = new ArrayList();
  
  public void addRequestInterceptor(HttpRequestInterceptor itcp)
  {
    if (itcp == null) {
      return;
    }
    requestInterceptors.add(itcp);
  }
  
  public void addRequestInterceptor(HttpRequestInterceptor itcp, int index)
  {
    if (itcp == null) {
      return;
    }
    requestInterceptors.add(index, itcp);
  }
  
  public void addResponseInterceptor(HttpResponseInterceptor itcp, int index)
  {
    if (itcp == null) {
      return;
    }
    responseInterceptors.add(index, itcp);
  }
  
  public void removeRequestInterceptorByClass(Class<? extends HttpRequestInterceptor> clazz)
  {
    Iterator<HttpRequestInterceptor> it = requestInterceptors.iterator();
    while (it.hasNext())
    {
      Object request = it.next();
      if (request.getClass().equals(clazz)) {
        it.remove();
      }
    }
  }
  
  public void removeResponseInterceptorByClass(Class<? extends HttpResponseInterceptor> clazz)
  {
    Iterator<HttpResponseInterceptor> it = responseInterceptors.iterator();
    while (it.hasNext())
    {
      Object request = it.next();
      if (request.getClass().equals(clazz)) {
        it.remove();
      }
    }
  }
  
  public final void addInterceptor(HttpRequestInterceptor interceptor)
  {
    addRequestInterceptor(interceptor);
  }
  
  public final void addInterceptor(HttpRequestInterceptor interceptor, int index)
  {
    addRequestInterceptor(interceptor, index);
  }
  
  public int getRequestInterceptorCount()
  {
    return requestInterceptors.size();
  }
  
  public HttpRequestInterceptor getRequestInterceptor(int index)
  {
    if ((index < 0) || (index >= requestInterceptors.size())) {
      return null;
    }
    return (HttpRequestInterceptor)requestInterceptors.get(index);
  }
  
  public void clearRequestInterceptors()
  {
    requestInterceptors.clear();
  }
  
  public void addResponseInterceptor(HttpResponseInterceptor itcp)
  {
    if (itcp == null) {
      return;
    }
    responseInterceptors.add(itcp);
  }
  
  public final void addInterceptor(HttpResponseInterceptor interceptor)
  {
    addResponseInterceptor(interceptor);
  }
  
  public final void addInterceptor(HttpResponseInterceptor interceptor, int index)
  {
    addResponseInterceptor(interceptor, index);
  }
  
  public int getResponseInterceptorCount()
  {
    return responseInterceptors.size();
  }
  
  public HttpResponseInterceptor getResponseInterceptor(int index)
  {
    if ((index < 0) || (index >= responseInterceptors.size())) {
      return null;
    }
    return (HttpResponseInterceptor)responseInterceptors.get(index);
  }
  
  public void clearResponseInterceptors()
  {
    responseInterceptors.clear();
  }
  
  public void setInterceptors(List<?> list)
  {
    Args.notNull(list, "Inteceptor list");
    requestInterceptors.clear();
    responseInterceptors.clear();
    for (Object obj : list)
    {
      if ((obj instanceof HttpRequestInterceptor)) {
        addInterceptor((HttpRequestInterceptor)obj);
      }
      if ((obj instanceof HttpResponseInterceptor)) {
        addInterceptor((HttpResponseInterceptor)obj);
      }
    }
  }
  
  public void clearInterceptors()
  {
    clearRequestInterceptors();
    clearResponseInterceptors();
  }
  
  public void process(HttpRequest request, HttpContext context)
    throws IOException, HttpException
  {
    for (HttpRequestInterceptor interceptor : requestInterceptors) {
      interceptor.process(request, context);
    }
  }
  
  public void process(HttpResponse response, HttpContext context)
    throws IOException, HttpException
  {
    for (HttpResponseInterceptor interceptor : responseInterceptors) {
      interceptor.process(response, context);
    }
  }
  
  protected void copyInterceptors(BasicHttpProcessor target)
  {
    requestInterceptors.clear();
    requestInterceptors.addAll(requestInterceptors);
    responseInterceptors.clear();
    responseInterceptors.addAll(responseInterceptors);
  }
  
  public BasicHttpProcessor copy()
  {
    BasicHttpProcessor clone = new BasicHttpProcessor();
    copyInterceptors(clone);
    return clone;
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    BasicHttpProcessor clone = (BasicHttpProcessor)super.clone();
    copyInterceptors(clone);
    return clone;
  }
}

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

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import org.apache.http.annotation.NotThreadSafe;

@NotThreadSafe
final class ChainBuilder<E>
{
  private final LinkedList<E> list;
  private final Map<Class<?>, E> uniqueClasses;
  
  public ChainBuilder()
  {
    list = new LinkedList();
    uniqueClasses = new HashMap();
  }
  
  private void ensureUnique(E e)
  {
    E previous = uniqueClasses.remove(e.getClass());
    if (previous != null) {
      list.remove(previous);
    }
    uniqueClasses.put(e.getClass(), e);
  }
  
  public ChainBuilder<E> addFirst(E e)
  {
    if (e == null) {
      return this;
    }
    ensureUnique(e);
    list.addFirst(e);
    return this;
  }
  
  public ChainBuilder<E> addLast(E e)
  {
    if (e == null) {
      return this;
    }
    ensureUnique(e);
    list.addLast(e);
    return this;
  }
  
  public ChainBuilder<E> addAllFirst(Collection<E> c)
  {
    if (c == null) {
      return this;
    }
    for (E e : c) {
      addFirst(e);
    }
    return this;
  }
  
  public ChainBuilder<E> addAllFirst(E... c)
  {
    if (c == null) {
      return this;
    }
    for (E e : c) {
      addFirst(e);
    }
    return this;
  }
  
  public ChainBuilder<E> addAllLast(Collection<E> c)
  {
    if (c == null) {
      return this;
    }
    for (E e : c) {
      addLast(e);
    }
    return this;
  }
  
  public ChainBuilder<E> addAllLast(E... c)
  {
    if (c == null) {
      return this;
    }
    for (E e : c) {
      addLast(e);
    }
    return this;
  }
  
  public LinkedList<E> build()
  {
    return new LinkedList(list);
  }
}

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

import org.apache.http.util.Args;

@Deprecated
public final class DefaultedHttpContext
  implements HttpContext
{
  private final HttpContext local;
  private final HttpContext defaults;
  
  public DefaultedHttpContext(HttpContext local, HttpContext defaults)
  {
    this.local = ((HttpContext)Args.notNull(local, "HTTP context"));
    this.defaults = defaults;
  }
  
  public Object getAttribute(String id)
  {
    Object obj = local.getAttribute(id);
    if (obj == null) {
      return defaults.getAttribute(id);
    }
    return obj;
  }
  
  public Object removeAttribute(String id)
  {
    return local.removeAttribute(id);
  }
  
  public void setAttribute(String id, Object obj)
  {
    local.setAttribute(id, obj);
  }
  
  public HttpContext getDefaults()
  {
    return defaults;
  }
  
  public String toString()
  {
    StringBuilder buf = new StringBuilder();
    buf.append("[local: ").append(local);
    buf.append("defaults: ").append(defaults);
    buf.append("]");
    return buf.toString();
  }
}

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

@Deprecated
public abstract interface ExecutionContext
{
  public static final String HTTP_CONNECTION = "http.connection";
  public static final String HTTP_REQUEST = "http.request";
  public static final String HTTP_RESPONSE = "http.response";
  public static final String HTTP_TARGET_HOST = "http.target_host";
  @Deprecated
  public static final String HTTP_PROXY_HOST = "http.proxy_host";
  public static final String HTTP_REQ_SENT = "http.request_sent";
}

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

import java.nio.charset.Charset;
import org.apache.http.Consts;

public final class HTTP
{
  public static final int CR = 13;
  public static final int LF = 10;
  public static final int SP = 32;
  public static final int HT = 9;
  public static final String TRANSFER_ENCODING = "Transfer-Encoding";
  public static final String CONTENT_LEN = "Content-Length";
  public static final String CONTENT_TYPE = "Content-Type";
  public static final String CONTENT_ENCODING = "Content-Encoding";
  public static final String EXPECT_DIRECTIVE = "Expect";
  public static final String CONN_DIRECTIVE = "Connection";
  public static final String TARGET_HOST = "Host";
  public static final String USER_AGENT = "User-Agent";
  public static final String DATE_HEADER = "Date";
  public static final String SERVER_HEADER = "Server";
  public static final String EXPECT_CONTINUE = "100-continue";
  public static final String CONN_CLOSE = "Close";
  public static final String CONN_KEEP_ALIVE = "Keep-Alive";
  public static final String CHUNK_CODING = "chunked";
  public static final String IDENTITY_CODING = "identity";
  public static final Charset DEF_CONTENT_CHARSET = Consts.ISO_8859_1;
  public static final Charset DEF_PROTOCOL_CHARSET = Consts.ASCII;
  @Deprecated
  public static final String UTF_8 = "UTF-8";
  @Deprecated
  public static final String UTF_16 = "UTF-16";
  @Deprecated
  public static final String US_ASCII = "US-ASCII";
  @Deprecated
  public static final String ASCII = "ASCII";
  @Deprecated
  public static final String ISO_8859_1 = "ISO-8859-1";
  @Deprecated
  public static final String DEFAULT_CONTENT_CHARSET = "ISO-8859-1";
  @Deprecated
  public static final String DEFAULT_PROTOCOL_CHARSET = "US-ASCII";
  @Deprecated
  public static final String OCTET_STREAM_TYPE = "application/octet-stream";
  @Deprecated
  public static final String PLAIN_TEXT_TYPE = "text/plain";
  @Deprecated
  public static final String CHARSET_PARAM = "; charset=";
  @Deprecated
  public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
  
  public static boolean isWhitespace(char ch)
  {
    return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n');
  }
}

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

public abstract interface HttpContext
{
  public static final String RESERVED_PREFIX = "http.";
  
  public abstract Object getAttribute(String paramString);
  
  public abstract void setAttribute(String paramString, Object paramObject);
  
  public abstract Object removeAttribute(String paramString);
}

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

import org.apache.http.HttpConnection;
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.util.Args;

@NotThreadSafe
public class HttpCoreContext
  implements HttpContext
{
  public static final String HTTP_CONNECTION = "http.connection";
  public static final String HTTP_REQUEST = "http.request";
  public static final String HTTP_RESPONSE = "http.response";
  public static final String HTTP_TARGET_HOST = "http.target_host";
  public static final String HTTP_REQ_SENT = "http.request_sent";
  private final HttpContext context;
  
  public static HttpCoreContext create()
  {
    return new HttpCoreContext(new BasicHttpContext());
  }
  
  public static HttpCoreContext adapt(HttpContext context)
  {
    Args.notNull(context, "HTTP context");
    if ((context instanceof HttpCoreContext)) {
      return (HttpCoreContext)context;
    }
    return new HttpCoreContext(context);
  }
  
  public HttpCoreContext(HttpContext context)
  {
    this.context = context;
  }
  
  public HttpCoreContext()
  {
    context = new BasicHttpContext();
  }
  
  public Object getAttribute(String id)
  {
    return context.getAttribute(id);
  }
  
  public void setAttribute(String id, Object obj)
  {
    context.setAttribute(id, obj);
  }
  
  public Object removeAttribute(String id)
  {
    return context.removeAttribute(id);
  }
  
  public <T> T getAttribute(String attribname, Class<T> clazz)
  {
    Args.notNull(clazz, "Attribute class");
    Object obj = getAttribute(attribname);
    if (obj == null) {
      return null;
    }
    return (T)clazz.cast(obj);
  }
  
  public <T extends HttpConnection> T getConnection(Class<T> clazz)
  {
    return (HttpConnection)getAttribute("http.connection", clazz);
  }
  
  public HttpConnection getConnection()
  {
    return (HttpConnection)getAttribute("http.connection", HttpConnection.class);
  }
  
  public HttpRequest getRequest()
  {
    return (HttpRequest)getAttribute("http.request", HttpRequest.class);
  }
  
  public boolean isRequestSent()
  {
    Boolean b = (Boolean)getAttribute("http.request_sent", Boolean.class);
    return (b != null) && (b.booleanValue());
  }
  
  public HttpResponse getResponse()
  {
    return (HttpResponse)getAttribute("http.response", HttpResponse.class);
  }
  
  public void setTargetHost(HttpHost host)
  {
    setAttribute("http.target_host", host);
  }
  
  public HttpHost getTargetHost()
  {
    return (HttpHost)getAttribute("http.target_host", HttpHost.class);
  }
}

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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.apache.http.annotation.GuardedBy;
import org.apache.http.annotation.ThreadSafe;

@ThreadSafe
public class HttpDateGenerator
{
  public static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";
  public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
  @GuardedBy("this")
  private final DateFormat dateformat;
  @GuardedBy("this")
  private long dateAsLong = 0L;
  @GuardedBy("this")
  private String dateAsText = null;
  
  public HttpDateGenerator()
  {
    dateformat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
    dateformat.setTimeZone(GMT);
  }
  
  public synchronized String getCurrentDate()
  {
    long now = System.currentTimeMillis();
    if (now - dateAsLong > 1000L)
    {
      dateAsText = dateformat.format(new Date(now));
      dateAsLong = now;
    }
    return dateAsText;
  }
}

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

import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;

public abstract interface HttpExpectationVerifier
{
  public abstract void verify(HttpRequest paramHttpRequest, HttpResponse paramHttpResponse, HttpContext paramHttpContext)
    throws HttpException;
}

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

import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponseInterceptor;

public abstract interface HttpProcessor
  extends HttpRequestInterceptor, HttpResponseInterceptor
{}

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

import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponseInterceptor;

public class HttpProcessorBuilder
{
  private ChainBuilder<HttpRequestInterceptor> requestChainBuilder;
  private ChainBuilder<HttpResponseInterceptor> responseChainBuilder;
  
  public static HttpProcessorBuilder create()
  {
    return new HttpProcessorBuilder();
  }
  
  private ChainBuilder<HttpRequestInterceptor> getRequestChainBuilder()
  {
    if (requestChainBuilder == null) {
      requestChainBuilder = new ChainBuilder();
    }
    return requestChainBuilder;
  }
  
  private ChainBuilder<HttpResponseInterceptor> getResponseChainBuilder()
  {
    if (responseChainBuilder == null) {
      responseChainBuilder = new ChainBuilder();
    }
    return responseChainBuilder;
  }
  
  public HttpProcessorBuilder addFirst(HttpRequestInterceptor e)
  {
    if (e == null) {
      return this;
    }
    getRequestChainBuilder().addFirst(e);
    return this;
  }
  
  public HttpProcessorBuilder addLast(HttpRequestInterceptor e)
  {
    if (e == null) {
      return this;
    }
    getRequestChainBuilder().addLast(e);
    return this;
  }
  
  public HttpProcessorBuilder add(HttpRequestInterceptor e)
  {
    return addLast(e);
  }
  
  public HttpProcessorBuilder addAllFirst(HttpRequestInterceptor... e)
  {
    if (e == null) {
      return this;
    }
    getRequestChainBuilder().addAllFirst(e);
    return this;
  }
  
  public HttpProcessorBuilder addAllLast(HttpRequestInterceptor... e)
  {
    if (e == null) {
      return this;
    }
    getRequestChainBuilder().addAllLast(e);
    return this;
  }
  
  public HttpProcessorBuilder addAll(HttpRequestInterceptor... e)
  {
    return addAllLast(e);
  }
  
  public HttpProcessorBuilder addFirst(HttpResponseInterceptor e)
  {
    if (e == null) {
      return this;
    }
    getResponseChainBuilder().addFirst(e);
    return this;
  }
  
  public HttpProcessorBuilder addLast(HttpResponseInterceptor e)
  {
    if (e == null) {
      return this;
    }
    getResponseChainBuilder().addLast(e);
    return this;
  }
  
  public HttpProcessorBuilder add(HttpResponseInterceptor e)
  {
    return addLast(e);
  }
  
  public HttpProcessorBuilder addAllFirst(HttpResponseInterceptor... e)
  {
    if (e == null) {
      return this;
    }
    getResponseChainBuilder().addAllFirst(e);
    return this;
  }
  
  public HttpProcessorBuilder addAllLast(HttpResponseInterceptor... e)
  {
    if (e == null) {
      return this;
    }
    getResponseChainBuilder().addAllLast(e);
    return this;
  }
  
  public HttpProcessorBuilder addAll(HttpResponseInterceptor... e)
  {
    return addAllLast(e);
  }
  
  public HttpProcessor build()
  {
    return new ImmutableHttpProcessor(requestChainBuilder != null ? requestChainBuilder.build() : null, responseChainBuilder != null ? responseChainBuilder.build() : null);
  }
}

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

import java.io.IOException;
import org.apache.http.HttpClientConnection;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.ProtocolException;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.StatusLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;

@Immutable
public class HttpRequestExecutor
{
  public static final int DEFAULT_WAIT_FOR_CONTINUE = 3000;
  private final int waitForContinue;
  
  public HttpRequestExecutor(int waitForContinue)
  {
    this.waitForContinue = Args.positive(waitForContinue, "Wait for continue time");
  }
  
  public HttpRequestExecutor()
  {
    this(3000);
  }
  
  protected boolean canResponseHaveBody(HttpRequest request, HttpResponse response)
  {
    if ("HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
      return false;
    }
    int status = response.getStatusLine().getStatusCode();
    return (status >= 200) && (status != 204) && (status != 304) && (status != 205);
  }
  
  public HttpResponse execute(HttpRequest request, HttpClientConnection conn, HttpContext context)
    throws IOException, HttpException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(conn, "Client connection");
    Args.notNull(context, "HTTP context");
    try
    {
      HttpResponse response = doSendRequest(request, conn, context);
      if (response == null) {}
      return doReceiveResponse(request, conn, context);
    }
    catch (IOException ex)
    {
      closeConnection(conn);
      throw ex;
    }
    catch (HttpException ex)
    {
      closeConnection(conn);
      throw ex;
    }
    catch (RuntimeException ex)
    {
      closeConnection(conn);
      throw ex;
    }
  }
  
  private static void closeConnection(HttpClientConnection conn)
  {
    try
    {
      conn.close();
    }
    catch (IOException ignore) {}
  }
  
  public void preProcess(HttpRequest request, HttpProcessor processor, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(processor, "HTTP processor");
    Args.notNull(context, "HTTP context");
    context.setAttribute("http.request", request);
    processor.process(request, context);
  }
  
  protected HttpResponse doSendRequest(HttpRequest request, HttpClientConnection conn, HttpContext context)
    throws IOException, HttpException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(conn, "Client connection");
    Args.notNull(context, "HTTP context");
    
    HttpResponse response = null;
    
    context.setAttribute("http.connection", conn);
    context.setAttribute("http.request_sent", Boolean.FALSE);
    
    conn.sendRequestHeader(request);
    if ((request instanceof HttpEntityEnclosingRequest))
    {
      boolean sendentity = true;
      ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
      if ((((HttpEntityEnclosingRequest)request).expectContinue()) && (!ver.lessEquals(HttpVersion.HTTP_1_0)))
      {
        conn.flush();
        if (conn.isResponseAvailable(waitForContinue))
        {
          response = conn.receiveResponseHeader();
          if (canResponseHaveBody(request, response)) {
            conn.receiveResponseEntity(response);
          }
          int status = response.getStatusLine().getStatusCode();
          if (status < 200)
          {
            if (status != 100) {
              throw new ProtocolException("Unexpected response: " + response.getStatusLine());
            }
            response = null;
          }
          else
          {
            sendentity = false;
          }
        }
      }
      if (sendentity) {
        conn.sendRequestEntity((HttpEntityEnclosingRequest)request);
      }
    }
    conn.flush();
    context.setAttribute("http.request_sent", Boolean.TRUE);
    return response;
  }
  
  protected HttpResponse doReceiveResponse(HttpRequest request, HttpClientConnection conn, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(conn, "Client connection");
    Args.notNull(context, "HTTP context");
    HttpResponse response = null;
    int statusCode = 0;
    while ((response == null) || (statusCode < 200))
    {
      response = conn.receiveResponseHeader();
      if (canResponseHaveBody(request, response)) {
        conn.receiveResponseEntity(response);
      }
      statusCode = response.getStatusLine().getStatusCode();
    }
    return response;
  }
  
  public void postProcess(HttpResponse response, HttpProcessor processor, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(response, "HTTP response");
    Args.notNull(processor, "HTTP processor");
    Args.notNull(context, "HTTP context");
    context.setAttribute("http.response", response);
    processor.process(response, context);
  }
}

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

import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;

public abstract interface HttpRequestHandler
{
  public abstract void handle(HttpRequest paramHttpRequest, HttpResponse paramHttpResponse, HttpContext paramHttpContext)
    throws HttpException, IOException;
}

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

import org.apache.http.HttpRequest;

public abstract interface HttpRequestHandlerMapper
{
  public abstract HttpRequestHandler lookup(HttpRequest paramHttpRequest);
}

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

import java.util.Map;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.util.Args;

@Deprecated
@ThreadSafe
public class HttpRequestHandlerRegistry
  implements HttpRequestHandlerResolver
{
  private final UriPatternMatcher<HttpRequestHandler> matcher;
  
  public HttpRequestHandlerRegistry()
  {
    matcher = new UriPatternMatcher();
  }
  
  public void register(String pattern, HttpRequestHandler handler)
  {
    Args.notNull(pattern, "URI request pattern");
    Args.notNull(handler, "Request handler");
    matcher.register(pattern, handler);
  }
  
  public void unregister(String pattern)
  {
    matcher.unregister(pattern);
  }
  
  public void setHandlers(Map<String, HttpRequestHandler> map)
  {
    matcher.setObjects(map);
  }
  
  public Map<String, HttpRequestHandler> getHandlers()
  {
    return matcher.getObjects();
  }
  
  public HttpRequestHandler lookup(String requestURI)
  {
    return (HttpRequestHandler)matcher.lookup(requestURI);
  }
}

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

@Deprecated
public abstract interface HttpRequestHandlerResolver
{
  public abstract HttpRequestHandler lookup(String paramString);
}

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

import java.util.List;
import org.apache.http.HttpRequestInterceptor;

@Deprecated
public abstract interface HttpRequestInterceptorList
{
  public abstract void addRequestInterceptor(HttpRequestInterceptor paramHttpRequestInterceptor);
  
  public abstract void addRequestInterceptor(HttpRequestInterceptor paramHttpRequestInterceptor, int paramInt);
  
  public abstract int getRequestInterceptorCount();
  
  public abstract HttpRequestInterceptor getRequestInterceptor(int paramInt);
  
  public abstract void clearRequestInterceptors();
  
  public abstract void removeRequestInterceptorByClass(Class<? extends HttpRequestInterceptor> paramClass);
  
  public abstract void setInterceptors(List<?> paramList);
}

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

import java.util.List;
import org.apache.http.HttpResponseInterceptor;

@Deprecated
public abstract interface HttpResponseInterceptorList
{
  public abstract void addResponseInterceptor(HttpResponseInterceptor paramHttpResponseInterceptor);
  
  public abstract void addResponseInterceptor(HttpResponseInterceptor paramHttpResponseInterceptor, int paramInt);
  
  public abstract int getResponseInterceptorCount();
  
  public abstract HttpResponseInterceptor getResponseInterceptor(int paramInt);
  
  public abstract void clearResponseInterceptors();
  
  public abstract void removeResponseInterceptorByClass(Class<? extends HttpResponseInterceptor> paramClass);
  
  public abstract void setInterceptors(List<?> paramList);
}

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

import org.apache.http.HttpRequest;
import org.apache.http.RequestLine;

@Deprecated
class HttpService$HttpRequestHandlerResolverAdapter
  implements HttpRequestHandlerMapper
{
  private final HttpRequestHandlerResolver resolver;
  
  public HttpService$HttpRequestHandlerResolverAdapter(HttpRequestHandlerResolver resolver)
  {
    this.resolver = resolver;
  }
  
  public HttpRequestHandler lookup(HttpRequest request)
  {
    return resolver.lookup(request.getRequestLine().getUri());
  }
}

/* Location:
 * Qualified Name:     org.apache.http.protocol.HttpService.HttpRequestHandlerResolverAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.protocol;

import java.io.IOException;
import org.apache.http.ConnectionReuseStrategy;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseFactory;
import org.apache.http.HttpServerConnection;
import org.apache.http.HttpVersion;
import org.apache.http.MethodNotSupportedException;
import org.apache.http.ProtocolException;
import org.apache.http.RequestLine;
import org.apache.http.StatusLine;
import org.apache.http.UnsupportedHttpVersionException;
import org.apache.http.annotation.Immutable;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;
import org.apache.http.util.EncodingUtils;
import org.apache.http.util.EntityUtils;

@Immutable
public class HttpService
{
  private volatile HttpParams params = null;
  private volatile HttpProcessor processor = null;
  private volatile HttpRequestHandlerMapper handlerMapper = null;
  private volatile ConnectionReuseStrategy connStrategy = null;
  private volatile HttpResponseFactory responseFactory = null;
  private volatile HttpExpectationVerifier expectationVerifier = null;
  
  @Deprecated
  public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpExpectationVerifier expectationVerifier, HttpParams params)
  {
    this(processor, connStrategy, responseFactory, new HttpRequestHandlerResolverAdapter(handlerResolver), expectationVerifier);
  }
  
  @Deprecated
  public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params)
  {
    this(processor, connStrategy, responseFactory, new HttpRequestHandlerResolverAdapter(handlerResolver), null);
  }
  
  @Deprecated
  public HttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory)
  {
    setHttpProcessor(proc);
    setConnReuseStrategy(connStrategy);
    setResponseFactory(responseFactory);
  }
  
  public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerMapper handlerMapper, HttpExpectationVerifier expectationVerifier)
  {
    this.processor = ((HttpProcessor)Args.notNull(processor, "HTTP processor"));
    this.connStrategy = (connStrategy != null ? connStrategy : DefaultConnectionReuseStrategy.INSTANCE);
    
    this.responseFactory = (responseFactory != null ? responseFactory : DefaultHttpResponseFactory.INSTANCE);
    
    this.handlerMapper = handlerMapper;
    this.expectationVerifier = expectationVerifier;
  }
  
  public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerMapper handlerMapper)
  {
    this(processor, connStrategy, responseFactory, handlerMapper, null);
  }
  
  public HttpService(HttpProcessor processor, HttpRequestHandlerMapper handlerMapper)
  {
    this(processor, null, null, handlerMapper, null);
  }
  
  @Deprecated
  public void setHttpProcessor(HttpProcessor processor)
  {
    Args.notNull(processor, "HTTP processor");
    this.processor = processor;
  }
  
  @Deprecated
  public void setConnReuseStrategy(ConnectionReuseStrategy connStrategy)
  {
    Args.notNull(connStrategy, "Connection reuse strategy");
    this.connStrategy = connStrategy;
  }
  
  @Deprecated
  public void setResponseFactory(HttpResponseFactory responseFactory)
  {
    Args.notNull(responseFactory, "Response factory");
    this.responseFactory = responseFactory;
  }
  
  @Deprecated
  public void setParams(HttpParams params)
  {
    this.params = params;
  }
  
  @Deprecated
  public void setHandlerResolver(HttpRequestHandlerResolver handlerResolver)
  {
    handlerMapper = new HttpRequestHandlerResolverAdapter(handlerResolver);
  }
  
  @Deprecated
  public void setExpectationVerifier(HttpExpectationVerifier expectationVerifier)
  {
    this.expectationVerifier = expectationVerifier;
  }
  
  @Deprecated
  public HttpParams getParams()
  {
    return params;
  }
  
  public void handleRequest(HttpServerConnection conn, HttpContext context)
    throws IOException, HttpException
  {
    context.setAttribute("http.connection", conn);
    
    HttpResponse response = null;
    try
    {
      HttpRequest request = conn.receiveRequestHeader();
      if ((request instanceof HttpEntityEnclosingRequest)
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