com.crashlytics.tools.android_2.1.0

inExec)
  {
    CacheConfig config = cacheConfig != null ? cacheConfig : CacheConfig.DEFAULT;
    ResourceFactory resourceFactory = this.resourceFactory;
    if (resourceFactory == null) {
      if (cacheDir == null) {
        resourceFactory = new HeapResourceFactory();
      } else {
        resourceFactory = new FileResourceFactory(cacheDir);
      }
    }
    HttpCacheStorage storage = this.storage;
    if (storage == null) {
      if (cacheDir == null)
      {
        storage = new BasicHttpCacheStorage(cacheConfig);
      }
      else
      {
        ManagedHttpCacheStorage managedStorage = new ManagedHttpCacheStorage(cacheConfig);
        addCloseable(managedStorage);
        storage = managedStorage;
      }
    }
    AsynchronousValidator revalidator = createAsynchronousRevalidator(config);
    CacheKeyGenerator uriExtractor = new CacheKeyGenerator();
    
    HttpCacheInvalidator cacheInvalidator = httpCacheInvalidator;
    if (cacheInvalidator == null) {
      cacheInvalidator = new CacheInvalidator(uriExtractor, storage);
    }
    return new CachingExec(mainExec, new BasicHttpCache(resourceFactory, storage, config, uriExtractor, cacheInvalidator), config, revalidator);
  }
  
  private AsynchronousValidator createAsynchronousRevalidator(CacheConfig config)
  {
    if (config.getAsynchronousWorkersMax() > 0)
    {
      SchedulingStrategy configuredSchedulingStrategy = createSchedulingStrategy(config);
      AsynchronousValidator revalidator = new AsynchronousValidator(configuredSchedulingStrategy);
      
      addCloseable(revalidator);
      return revalidator;
    }
    return null;
  }
  
  private SchedulingStrategy createSchedulingStrategy(CacheConfig config)
  {
    return schedulingStrategy != null ? schedulingStrategy : new ImmediateSchedulingStrategy(config);
  }
}

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

import java.io.File;
import org.apache.http.annotation.Immutable;
import org.apache.http.impl.client.CloseableHttpClient;

@Immutable
public class CachingHttpClients
{
  public static CachingHttpClientBuilder custom()
  {
    return CachingHttpClientBuilder.create();
  }
  
  public static CloseableHttpClient createMemoryBound()
  {
    return CachingHttpClientBuilder.create().build();
  }
  
  public static CloseableHttpClient createFileBound(File cacheDir)
  {
    return CachingHttpClientBuilder.create().setCacheDir(cacheDir).build();
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

class CombinedEntity$ResourceStream
  extends FilterInputStream
{
  protected CombinedEntity$ResourceStream(CombinedEntity paramCombinedEntity, InputStream in)
  {
    super(in);
  }
  
  public void close()
    throws IOException
  {
    try
    {
      super.close();
    }
    finally
    {
      CombinedEntity.access$000(this$0);
    }
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.SequenceInputStream;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.client.cache.Resource;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.util.Args;

@NotThreadSafe
class CombinedEntity
  extends AbstractHttpEntity
{
  private final Resource resource;
  private final InputStream combinedStream;
  
  CombinedEntity(Resource resource, InputStream instream)
    throws IOException
  {
    this.resource = resource;
    combinedStream = new SequenceInputStream(new ResourceStream(resource.getInputStream()), instream);
  }
  
  public long getContentLength()
  {
    return -1L;
  }
  
  public boolean isRepeatable()
  {
    return false;
  }
  
  public boolean isStreaming()
  {
    return true;
  }
  
  public InputStream getContent()
    throws IOException, IllegalStateException
  {
    return combinedStream;
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    InputStream instream = getContent();
    try
    {
      byte[] tmp = new byte['?'];
      int l;
      while ((l = instream.read(tmp)) != -1) {
        outstream.write(tmp, 0, l);
      }
    }
    finally
    {
      instream.close();
    }
  }
  
  private void dispose()
  {
    resource.dispose();
  }
  
  class ResourceStream
    extends FilterInputStream
  {
    protected ResourceStream(InputStream in)
    {
      super();
    }
    
    public void close()
      throws IOException
    {
      try
      {
        super.close();
      }
      finally
      {
        CombinedEntity.this.dispose();
      }
    }
  }
}

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

import java.util.Map;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.ProtocolException;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpRequestWrapper;

@Immutable
class ConditionalRequestBuilder
{
  public HttpRequestWrapper buildConditionalRequest(HttpRequestWrapper request, HttpCacheEntry cacheEntry)
    throws ProtocolException
  {
    HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
    newRequest.setHeaders(request.getAllHeaders());
    Header eTag = cacheEntry.getFirstHeader("ETag");
    if (eTag != null) {
      newRequest.setHeader("If-None-Match", eTag.getValue());
    }
    Header lastModified = cacheEntry.getFirstHeader("Last-Modified");
    if (lastModified != null) {
      newRequest.setHeader("If-Modified-Since", lastModified.getValue());
    }
    boolean mustRevalidate = false;
    for (Header h : cacheEntry.getHeaders("Cache-Control")) {
      for (HeaderElement elt : h.getElements()) {
        if (("must-revalidate".equalsIgnoreCase(elt.getName())) || ("proxy-revalidate".equalsIgnoreCase(elt.getName())))
        {
          mustRevalidate = true;
          break;
        }
      }
    }
    if (mustRevalidate) {
      newRequest.addHeader("Cache-Control", "max-age=0");
    }
    return newRequest;
  }
  
  public HttpRequestWrapper buildConditionalRequestFromVariants(HttpRequestWrapper request, Map<String, Variant> variants)
  {
    HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
    newRequest.setHeaders(request.getAllHeaders());
    
    StringBuilder etags = new StringBuilder();
    boolean first = true;
    for (String etag : variants.keySet())
    {
      if (!first) {
        etags.append(",");
      }
      first = false;
      etags.append(etag);
    }
    newRequest.setHeader("If-None-Match", etags.toString());
    return newRequest;
  }
  
  public HttpRequestWrapper buildUnconditionalRequest(HttpRequestWrapper request, HttpCacheEntry entry)
  {
    HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
    newRequest.setHeaders(request.getAllHeaders());
    newRequest.addHeader("Cache-Control", "no-cache");
    newRequest.addHeader("Pragma", "no-cache");
    newRequest.removeHeaders("If-Range");
    newRequest.removeHeaders("If-Match");
    newRequest.removeHeaders("If-None-Match");
    newRequest.removeHeaders("If-Unmodified-Since");
    newRequest.removeHeaders("If-Modified-Since");
    return newRequest;
  }
}

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

import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.http.annotation.ThreadSafe;

@ThreadSafe
public class DefaultFailureCache
  implements FailureCache
{
  static final int DEFAULT_MAX_SIZE = 1000;
  static final int MAX_UPDATE_TRIES = 10;
  private final int maxSize;
  private final ConcurrentMap<String, FailureCacheValue> storage;
  
  public DefaultFailureCache()
  {
    this(1000);
  }
  
  public DefaultFailureCache(int maxSize)
  {
    this.maxSize = maxSize;
    storage = new ConcurrentHashMap();
  }
  
  public int getErrorCount(String identifier)
  {
    if (identifier == null) {
      throw new IllegalArgumentException("identifier may not be null");
    }
    FailureCacheValue storedErrorCode = (FailureCacheValue)storage.get(identifier);
    return storedErrorCode != null ? storedErrorCode.getErrorCount() : 0;
  }
  
  public void resetErrorCount(String identifier)
  {
    if (identifier == null) {
      throw new IllegalArgumentException("identifier may not be null");
    }
    storage.remove(identifier);
  }
  
  public void increaseErrorCount(String identifier)
  {
    if (identifier == null) {
      throw new IllegalArgumentException("identifier may not be null");
    }
    updateValue(identifier);
    removeOldestEntryIfMapSizeExceeded();
  }
  
  private void updateValue(String identifier)
  {
    for (int i = 0; i < 10; i++)
    {
      FailureCacheValue oldValue = (FailureCacheValue)storage.get(identifier);
      if (oldValue == null)
      {
        FailureCacheValue newValue = new FailureCacheValue(identifier, 1);
        if (storage.putIfAbsent(identifier, newValue) == null) {
          return;
        }
      }
      else
      {
        int errorCount = oldValue.getErrorCount();
        if (errorCount == Integer.MAX_VALUE) {
          return;
        }
        FailureCacheValue newValue = new FailureCacheValue(identifier, errorCount + 1);
        if (storage.replace(identifier, oldValue, newValue)) {
          return;
        }
      }
    }
  }
  
  private void removeOldestEntryIfMapSizeExceeded()
  {
    if (storage.size() > maxSize)
    {
      FailureCacheValue valueWithOldestTimestamp = findValueWithOldestTimestamp();
      if (valueWithOldestTimestamp != null) {
        storage.remove(valueWithOldestTimestamp.getKey(), valueWithOldestTimestamp);
      }
    }
  }
  
  private FailureCacheValue findValueWithOldestTimestamp()
  {
    long oldestTimestamp = Long.MAX_VALUE;
    FailureCacheValue oldestValue = null;
    for (Map.Entry<String, FailureCacheValue> storageEntry : storage.entrySet())
    {
      FailureCacheValue value = (FailureCacheValue)storageEntry.getValue();
      long creationTimeInNanos = value.getCreationTimeInNanos();
      if (creationTimeInNanos < oldestTimestamp)
      {
        oldestTimestamp = creationTimeInNanos;
        oldestValue = (FailureCacheValue)storageEntry.getValue();
      }
    }
    return oldestValue;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializationException;
import org.apache.http.client.cache.HttpCacheEntrySerializer;

@Immutable
public class DefaultHttpCacheEntrySerializer
  implements HttpCacheEntrySerializer
{
  public void writeTo(HttpCacheEntry cacheEntry, OutputStream os)
    throws IOException
  {
    ObjectOutputStream oos = new ObjectOutputStream(os);
    try
    {
      oos.writeObject(cacheEntry);
    }
    finally
    {
      oos.close();
    }
  }
  
  public HttpCacheEntry readFrom(InputStream is)
    throws IOException
  {
    ObjectInputStream ois = new ObjectInputStream(is);
    try
    {
      return (HttpCacheEntry)ois.readObject();
    }
    catch (ClassNotFoundException ex)
    {
      throw new HttpCacheEntrySerializationException("Class not found: " + ex.getMessage(), ex);
    }
    finally
    {
      ois.close();
    }
  }
}

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

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.http.annotation.ThreadSafe;

@ThreadSafe
public class ExponentialBackOffSchedulingStrategy
  implements SchedulingStrategy
{
  public static final long DEFAULT_BACK_OFF_RATE = 10L;
  public static final long DEFAULT_INITIAL_EXPIRY_IN_MILLIS = TimeUnit.SECONDS.toMillis(6L);
  public static final long DEFAULT_MAX_EXPIRY_IN_MILLIS = TimeUnit.SECONDS.toMillis(86400L);
  private final long backOffRate;
  private final long initialExpiryInMillis;
  private final long maxExpiryInMillis;
  private final ScheduledExecutorService executor;
  
  public ExponentialBackOffSchedulingStrategy(CacheConfig cacheConfig)
  {
    this(cacheConfig, 10L, DEFAULT_INITIAL_EXPIRY_IN_MILLIS, DEFAULT_MAX_EXPIRY_IN_MILLIS);
  }
  
  public ExponentialBackOffSchedulingStrategy(CacheConfig cacheConfig, long backOffRate, long initialExpiryInMillis, long maxExpiryInMillis)
  {
    this(createThreadPoolFromCacheConfig(cacheConfig), backOffRate, initialExpiryInMillis, maxExpiryInMillis);
  }
  
  private static ScheduledThreadPoolExecutor createThreadPoolFromCacheConfig(CacheConfig cacheConfig)
  {
    ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(cacheConfig.getAsynchronousWorkersMax());
    
    scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    return scheduledThreadPoolExecutor;
  }
  
  ExponentialBackOffSchedulingStrategy(ScheduledExecutorService executor, long backOffRate, long initialExpiryInMillis, long maxExpiryInMillis)
  {
    this.executor = ((ScheduledExecutorService)checkNotNull("executor", executor));
    this.backOffRate = checkNotNegative("backOffRate", backOffRate);
    this.initialExpiryInMillis = checkNotNegative("initialExpiryInMillis", initialExpiryInMillis);
    this.maxExpiryInMillis = checkNotNegative("maxExpiryInMillis", maxExpiryInMillis);
  }
  
  public void schedule(AsynchronousValidationRequest revalidationRequest)
  {
    checkNotNull("revalidationRequest", revalidationRequest);
    int consecutiveFailedAttempts = revalidationRequest.getConsecutiveFailedAttempts();
    long delayInMillis = calculateDelayInMillis(consecutiveFailedAttempts);
    executor.schedule(revalidationRequest, delayInMillis, TimeUnit.MILLISECONDS);
  }
  
  public void close()
  {
    executor.shutdown();
  }
  
  public long getBackOffRate()
  {
    return backOffRate;
  }
  
  public long getInitialExpiryInMillis()
  {
    return initialExpiryInMillis;
  }
  
  public long getMaxExpiryInMillis()
  {
    return maxExpiryInMillis;
  }
  
  protected long calculateDelayInMillis(int consecutiveFailedAttempts)
  {
    if (consecutiveFailedAttempts > 0)
    {
      long delayInSeconds = (initialExpiryInMillis * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
      
      return Math.min(delayInSeconds, maxExpiryInMillis);
    }
    return 0L;
  }
  
  protected static <T> T checkNotNull(String parameterName, T value)
  {
    if (value == null) {
      throw new IllegalArgumentException(parameterName + " may not be null");
    }
    return value;
  }
  
  protected static long checkNotNegative(String parameterName, long value)
  {
    if (value < 0L) {
      throw new IllegalArgumentException(parameterName + " may not be negative");
    }
    return value;
  }
}

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

public abstract interface FailureCache
{
  public abstract int getErrorCount(String paramString);
  
  public abstract void resetErrorCount(String paramString);
  
  public abstract void increaseErrorCount(String paramString);
}

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

import org.apache.http.annotation.Immutable;

@Immutable
public class FailureCacheValue
{
  private final long creationTimeInNanos;
  private final String key;
  private final int errorCount;
  
  public FailureCacheValue(String key, int errorCount)
  {
    creationTimeInNanos = System.nanoTime();
    this.key = key;
    this.errorCount = errorCount;
  }
  
  public long getCreationTimeInNanos()
  {
    return creationTimeInNanos;
  }
  
  public String getKey()
  {
    return key;
  }
  
  public int getErrorCount()
  {
    return errorCount;
  }
  
  public String toString()
  {
    return "[entry creationTimeInNanos=" + creationTimeInNanos + "; " + "key=" + key + "; errorCount=" + errorCount + ']';
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.client.cache.Resource;

@ThreadSafe
public class FileResource
  implements Resource
{
  private static final long serialVersionUID = 4132244415919043397L;
  private final File file;
  private volatile boolean disposed;
  
  public FileResource(File file)
  {
    this.file = file;
    disposed = false;
  }
  
  synchronized File getFile()
  {
    return file;
  }
  
  public synchronized InputStream getInputStream()
    throws IOException
  {
    return new FileInputStream(file);
  }
  
  public synchronized long length()
  {
    return file.length();
  }
  
  public synchronized void dispose()
  {
    if (disposed) {
      return;
    }
    disposed = true;
    file.delete();
  }
}

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.InputLimit;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;

@Immutable
public class FileResourceFactory
  implements ResourceFactory
{
  private final File cacheDir;
  private final BasicIdGenerator idgen;
  
  public FileResourceFactory(File cacheDir)
  {
    this.cacheDir = cacheDir;
    idgen = new BasicIdGenerator();
  }
  
  private File generateUniqueCacheFile(String requestId)
  {
    StringBuilder buffer = new StringBuilder();
    idgen.generate(buffer);
    buffer.append('.');
    int len = Math.min(requestId.length(), 100);
    for (int i = 0; i < len; i++)
    {
      char ch = requestId.charAt(i);
      if ((Character.isLetterOrDigit(ch)) || (ch == '.')) {
        buffer.append(ch);
      } else {
        buffer.append('-');
      }
    }
    return new File(cacheDir, buffer.toString());
  }
  
  public Resource generate(String requestId, InputStream instream, InputLimit limit)
    throws IOException
  {
    File file = generateUniqueCacheFile(requestId);
    FileOutputStream outstream = new FileOutputStream(file);
    try
    {
      byte[] buf = new byte['?'];
      long total = 0L;
      int l;
      while ((l = instream.read(buf)) != -1)
      {
        outstream.write(buf, 0, l);
        total += l;
        if ((limit != null) && (total > limit.getValue())) {
          limit.reached();
        }
      }
    }
    finally
    {
      outstream.close();
    }
    return new FileResource(file);
  }
  
  public Resource copy(String requestId, Resource resource)
    throws IOException
  {
    File file = generateUniqueCacheFile(requestId);
    if ((resource instanceof FileResource))
    {
      File src = ((FileResource)resource).getFile();
      IOUtils.copyFile(src, file);
    }
    else
    {
      FileOutputStream out = new FileOutputStream(file);
      IOUtils.copyAndClose(resource.getInputStream(), out);
    }
    return new FileResource(file);
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.Resource;

@Immutable
public class HeapResource
  implements Resource
{
  private static final long serialVersionUID = -2078599905620463394L;
  private final byte[] b;
  
  public HeapResource(byte[] b)
  {
    this.b = b;
  }
  
  byte[] getByteArray()
  {
    return b;
  }
  
  public InputStream getInputStream()
  {
    return new ByteArrayInputStream(b);
  }
  
  public long length()
  {
    return b.length;
  }
  
  public void dispose() {}
}

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.InputLimit;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;

@Immutable
public class HeapResourceFactory
  implements ResourceFactory
{
  public Resource generate(String requestId, InputStream instream, InputLimit limit)
    throws IOException
  {
    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    byte[] buf = new byte['?'];
    long total = 0L;
    int l;
    while ((l = instream.read(buf)) != -1)
    {
      outstream.write(buf, 0, l);
      total += l;
      if ((limit != null) && (total > limit.getValue())) {
        limit.reached();
      }
    }
    return createResource(outstream.toByteArray());
  }
  
  public Resource copy(String requestId, Resource resource)
    throws IOException
  {
    byte[] body;
    byte[] body;
    if ((resource instanceof HeapResource))
    {
      body = ((HeapResource)resource).getByteArray();
    }
    else
    {
      ByteArrayOutputStream outstream = new ByteArrayOutputStream();
      IOUtils.copyAndClose(resource.getInputStream(), outstream);
      body = outstream.toByteArray();
    }
    return createResource(body);
  }
  
  Resource createResource(byte[] buf)
  {
    return new HeapResource(buf);
  }
}

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

import java.io.IOException;
import java.util.Date;
import java.util.Map;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.cache.HttpCacheEntry;

abstract interface HttpCache
{
  public abstract void flushCacheEntriesFor(HttpHost paramHttpHost, HttpRequest paramHttpRequest)
    throws IOException;
  
  public abstract void flushInvalidatedCacheEntriesFor(HttpHost paramHttpHost, HttpRequest paramHttpRequest)
    throws IOException;
  
  public abstract void flushInvalidatedCacheEntriesFor(HttpHost paramHttpHost, HttpRequest paramHttpRequest, HttpResponse paramHttpResponse);
  
  public abstract HttpCacheEntry getCacheEntry(HttpHost paramHttpHost, HttpRequest paramHttpRequest)
    throws IOException;
  
  public abstract Map<String, Variant> getVariantCacheEntriesWithEtags(HttpHost paramHttpHost, HttpRequest paramHttpRequest)
    throws IOException;
  
  public abstract HttpResponse cacheAndReturnResponse(HttpHost paramHttpHost, HttpRequest paramHttpRequest, HttpResponse paramHttpResponse, Date paramDate1, Date paramDate2)
    throws IOException;
  
  public abstract HttpCacheEntry updateCacheEntry(HttpHost paramHttpHost, HttpRequest paramHttpRequest, HttpCacheEntry paramHttpCacheEntry, HttpResponse paramHttpResponse, Date paramDate1, Date paramDate2)
    throws IOException;
  
  public abstract HttpCacheEntry updateVariantCacheEntry(HttpHost paramHttpHost, HttpRequest paramHttpRequest, HttpCacheEntry paramHttpCacheEntry, HttpResponse paramHttpResponse, Date paramDate1, Date paramDate2, String paramString)
    throws IOException;
  
  public abstract void reuseVariantEntryFor(HttpHost paramHttpHost, HttpRequest paramHttpRequest, Variant paramVariant)
    throws IOException;
}

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

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import org.apache.http.annotation.Immutable;

@Immutable
class IOUtils
{
  static void copy(InputStream in, OutputStream out)
    throws IOException
  {
    byte[] buf = new byte['?'];
    int len;
    while ((len = in.read(buf)) != -1) {
      out.write(buf, 0, len);
    }
  }
  
  static void closeSilently(Closeable closable)
  {
    try
    {
      closable.close();
    }
    catch (IOException ignore) {}
  }
  
  static void copyAndClose(InputStream in, OutputStream out)
    throws IOException
  {
    try
    {
      copy(in, out);
      in.close();
      out.close();
    }
    catch (IOException ex)
    {
      closeSilently(in);
      closeSilently(out);
      
      throw ex;
    }
  }
  
  static void copyFile(File in, File out)
    throws IOException
  {
    RandomAccessFile f1 = new RandomAccessFile(in, "r");
    RandomAccessFile f2 = new RandomAccessFile(out, "rw");
    try
    {
      FileChannel c1 = f1.getChannel();
      FileChannel c2 = f2.getChannel();
      try
      {
        c1.transferTo(0L, f1.length(), c2);
        c1.close();
        c2.close();
      }
      catch (IOException ex)
      {
        closeSilently(c1);
        closeSilently(c2);
        
        throw ex;
      }
      f1.close();
      f2.close();
    }
    catch (IOException ex)
    {
      closeSilently(f1);
      closeSilently(f2);
      
      throw ex;
    }
  }
}

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

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.http.annotation.ThreadSafe;

@ThreadSafe
public class ImmediateSchedulingStrategy
  implements SchedulingStrategy
{
  private final ExecutorService executor;
  
  public ImmediateSchedulingStrategy(CacheConfig cacheConfig)
  {
    this(new ThreadPoolExecutor(cacheConfig.getAsynchronousWorkersCore(), cacheConfig.getAsynchronousWorkersMax(), cacheConfig.getAsynchronousWorkerIdleLifetimeSecs(), TimeUnit.SECONDS, new ArrayBlockingQueue(cacheConfig.getRevalidationQueueSize())));
  }
  
  ImmediateSchedulingStrategy(ExecutorService executor)
  {
    this.executor = executor;
  }
  
  public void schedule(AsynchronousValidationRequest revalidationRequest)
  {
    if (revalidationRequest == null) {
      throw new IllegalArgumentException("AsynchronousValidationRequest may not be null");
    }
    executor.execute(revalidationRequest);
  }
  
  public void close()
  {
    executor.shutdown();
  }
  
  void awaitTermination(long timeout, TimeUnit unit)
    throws InterruptedException
  {
    executor.awaitTermination(timeout, unit);
  }
}

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

import java.io.Closeable;
import java.io.IOException;
import java.lang.ref.ReferenceQueue;
import java.util.HashSet;
import java.util.Set;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.cache.HttpCacheUpdateCallback;
import org.apache.http.client.cache.Resource;
import org.apache.http.util.Args;

@ThreadSafe
public class ManagedHttpCacheStorage
  implements HttpCacheStorage, Closeable
{
  private final CacheMap entries;
  private final ReferenceQueue<HttpCacheEntry> morque;
  private final Set<ResourceReference> resources;
  private volatile boolean shutdown;
  
  public ManagedHttpCacheStorage(CacheConfig config)
  {
    entries = new CacheMap(config.getMaxCacheEntries());
    morque = new ReferenceQueue();
    resources = new HashSet();
  }
  
  private void ensureValidState()
    throws IllegalStateException
  {
    if (shutdown) {
      throw new IllegalStateException("Cache has been shut down");
    }
  }
  
  private void keepResourceReference(HttpCacheEntry entry)
  {
    Resource resource = entry.getResource();
    if (resource != null)
    {
      ResourceReference ref = new ResourceReference(entry, morque);
      resources.add(ref);
    }
  }
  
  public void putEntry(String url, HttpCacheEntry entry)
    throws IOException
  {
    Args.notNull(url, "URL");
    Args.notNull(entry, "Cache entry");
    ensureValidState();
    synchronized (this)
    {
      entries.put(url, entry);
      keepResourceReference(entry);
    }
  }
  
  /* Error */
  public HttpCacheEntry getEntry(String url)
    throws IOException
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 20
    //   3: invokestatic 21	org/apache/http/util/Args:notNull	(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
    //   6: pop
    //   7: aload_0
    //   8: invokespecial 23	org/apache/http/impl/client/cache/ManagedHttpCacheStorage:ensureValidState	()V
    //   11: aload_0
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_0
    //   16: getfield 5	org/apache/http/impl/client/cache/ManagedHttpCacheStorage:entries	Lorg/apache/http/impl/client/cache/CacheMap;
    //   19: aload_1
    //   20: invokevirtual 26	org/apache/http/impl/client/cache/CacheMap:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   23: checkcast 27	org/apache/http/client/cache/HttpCacheEntry
    //   26: aload_2
    //   27: monitorexit
    //   28: areturn
    //   29: astore_3
    //   30: aload_2
    //   31: monitorexit
    //   32: aload_3
    //   33: athrow
    // Line number table:
    //   Java source line #99	-> byte code offset #0
    //   Java source line #100	-> byte code offset #7
    //   Java source line #101	-> byte code offset #11
    //   Java source line #102	-> byte code offset #15
    //   Java source line #103	-> byte code offset #29
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	34	0	this	ManagedHttpCacheStorage
    //   0	34	1	url	String
    //   13	18	2	Ljava/lang/Object;	Object
    //   29	4	3	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   15	28	29	finally
    //   29	32	29	finally
  }
  
  public void removeEntry(String url)
    throws IOException
  {
    Args.notNull(url, "URL");
    ensureValidState();
    synchronized (this)
    {
      entries.remove(url);
    }
  }
  
  public void updateEntry(String url, HttpCacheUpdateCallback callback)
    throws IOException
  {
    Args.notNull(url, "URL");
    Args.notNull(callback, "Callback");
    ensureValidState();
    synchronized (this)
    {
      HttpCacheEntry existing = (HttpCacheEntry)entries.get(url);
      HttpCacheEntry updated = callback.update(existing);
      entries.put(url, updated);
      if (existing != updated) {
        keepResourceReference(updated);
      }
    }
  }
  
  public void cleanResources()
  {
    if (shutdown) {
      return;
    }
    ResourceReference ref;
    while ((ref = (ResourceReference)morque.poll()) != null)
    {
      synchronized (this)
      {
        resources.remove(ref);
      }
      ref.getResource().dispose();
    }
  }
  
  public void shutdown()
  {
    if (shutdown) {
      return;
    }
    shutdown = true;
    synchronized (this)
    {
      entries.clear();
      for (ResourceReference ref : resources) {
        ref.getResource().dispose();
      }
      resources.clear();
      while (morque.poll() != null) {}
    }
  }
  
  public void close()
  {
    shutdown();
  }
}

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

import java.util.Locale;
import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.message.AbstractHttpMessage;
import org.apache.http.message.BasicStatusLine;
import org.apache.http.message.HeaderGroup;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;

@Immutable
final class OptionsHttp11Response
  extends AbstractHttpMessage
  implements HttpResponse
{
  private final StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, 501, "");
  private final ProtocolVersion version = HttpVersion.HTTP_1_1;
  
  public StatusLine getStatusLine()
  {
    return statusLine;
  }
  
  public void setStatusLine(StatusLine statusline) {}
  
  public void setStatusLine(ProtocolVersion ver, int code) {}
  
  public void setStatusLine(ProtocolVersion ver, int code, String reason) {}
  
  public void setStatusCode(int code)
    throws IllegalStateException
  {}
  
  public void setReasonPhrase(String reason)
    throws IllegalStateException
  {}
  
  public HttpEntity getEntity()
  {
    return null;
  }
  
  public void setEntity(HttpEntity entity) {}
  
  public Locale getLocale()
  {
    return null;
  }
  
  public void setLocale(Locale loc) {}
  
  public ProtocolVersion getProtocolVersion()
  {
    return version;
  }
  
  public boolean containsHeader(String name)
  {
    return headergroup.containsHeader(name);
  }
  
  public Header[] getHeaders(String name)
  {
    return headergroup.getHeaders(name);
  }
  
  public Header getFirstHeader(String name)
  {
    return headergroup.getFirstHeader(name);
  }
  
  public Header getLastHeader(String name)
  {
    return headergroup.getLastHeader(name);
  }
  
  public Header[] getAllHeaders()
  {
    return headergroup.getAllHeaders();
  }
  
  public void addHeader(Header header) {}
  
  public void addHeader(String name, String value) {}
  
  public void setHeader(Header header) {}
  
  public void setHeader(String name, String value) {}
  
  public void setHeaders(Header[] headers) {}
  
  public void removeHeader(Header header) {}
  
  public void removeHeaders(String name) {}
  
  public HeaderIterator headerIterator()
  {
    return headergroup.iterator();
  }
  
  public HeaderIterator headerIterator(String name)
  {
    return headergroup.iterator(name);
  }
  
  public HttpParams getParams()
  {
    if (params == null) {
      params = new BasicHttpParams();
    }
    return params;
  }
  
  public void setParams(HttpParams params) {}
}

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

import java.lang.reflect.Proxy;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.util.Args;

@NotThreadSafe
class Proxies
{
  public static CloseableHttpResponse enhanceResponse(HttpResponse original)
  {
    Args.notNull(original, "HTTP response");
    if ((original instanceof CloseableHttpResponse)) {
      return (CloseableHttpResponse)original;
    }
    return (CloseableHttpResponse)Proxy.newProxyInstance(ResponseProxyHandler.class.getClassLoader(), new Class[] { CloseableHttpResponse.class }, new ResponseProxyHandler(original));
  }
}

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

class RequestProtocolCompliance$1 {}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;

@Immutable
class RequestProtocolCompliance
{
  private final boolean weakETagOnPutDeleteAllowed;
  
  public RequestProtocolCompliance()
  {
    weakETagOnPutDeleteAllowed = false;
  }
  
  public RequestProtocolCompliance(boolean weakETagOnPutDeleteAllowed)
  {
    this.weakETagOnPutDeleteAllowed = weakETagOnPutDeleteAllowed;
  }
  
  private static final List<String> disallowedWithNoCache = Arrays.asList(new String[] { "min-fresh", "max-stale", "max-age" });
  
  public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request)
  {
    List<RequestProtocolError> theErrors = new ArrayList();
    
    RequestProtocolError anError = requestHasWeakETagAndRange(request);
    if (anError != null) {
      theErrors.add(anError);
    }
    if (!weakETagOnPutDeleteAllowed)
    {
      anError = requestHasWeekETagForPUTOrDELETEIfMatch(request);
      if (anError != null) {
        theErrors.add(anError);
      }
    }
    anError = requestContainsNoCacheDirectiveWithFieldName(request);
    if (anError != null) {
      theErrors.add(anError);
    }
    return theErrors;
  }
  
  public void makeRequestCompliant(HttpRequestWrapper request)
    throws ClientProtocolException
  {
    if (requestMustNotHaveEntity(request)) {
      ((HttpEntityEnclosingRequest)request).setEntity(null);
    }
    verifyRequestWithExpectContinueFlagHas100continueHeader(request);
    verifyOPTIONSRequestWithBodyHasContentType(request);
    decrementOPTIONSMaxForwardsIfGreaterThen0(request);
    stripOtherFreshnessDirectivesWithNoCache(request);
    if ((requestVersionIsTooLow(request)) || (re
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