com.crashlytics.tools.android_2.1.0

p/HttpRequestInterceptor;
    //   54: aload 5
    //   56: aload 4
    //   58: invokeinterface 27 3 0
    //   63: aload_0
    //   64: getfield 10	org/apache/http/impl/client/DecompressingHttpClient:backend	Lorg/apache/http/client/HttpClient;
    //   67: aload_1
    //   68: aload 5
    //   70: aload 4
    //   72: invokeinterface 28 4 0
    //   77: astore 6
    //   79: aload_0
    //   80: getfield 12	org/apache/http/impl/client/DecompressingHttpClient:contentEncodingInterceptor	Lorg/apache/http/HttpResponseInterceptor;
    //   83: aload 6
    //   85: aload 4
    //   87: invokeinterface 29 3 0
    //   92: getstatic 30	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   95: aload 4
    //   97: ldc 31
    //   99: invokeinterface 32 2 0
    //   104: invokevirtual 33	java/lang/Boolean:equals	(Ljava/lang/Object;)Z
    //   107: ifeq +30 -> 137
    //   110: aload 6
    //   112: ldc 34
    //   114: invokeinterface 35 2 0
    //   119: aload 6
    //   121: ldc 36
    //   123: invokeinterface 35 2 0
    //   128: aload 6
    //   130: ldc 37
    //   132: invokeinterface 35 2 0
    //   137: aload 6
    //   139: areturn
    //   140: astore 7
    //   142: aload 6
    //   144: invokeinterface 39 1 0
    //   149: invokestatic 40	org/apache/http/util/EntityUtils:consume	(Lorg/apache/http/HttpEntity;)V
    //   152: aload 7
    //   154: athrow
    //   155: astore 7
    //   157: aload 6
    //   159: invokeinterface 39 1 0
    //   164: invokestatic 40	org/apache/http/util/EntityUtils:consume	(Lorg/apache/http/HttpEntity;)V
    //   167: aload 7
    //   169: athrow
    //   170: astore 7
    //   172: aload 6
    //   174: invokeinterface 39 1 0
    //   179: invokestatic 40	org/apache/http/util/EntityUtils:consume	(Lorg/apache/http/HttpEntity;)V
    //   182: aload 7
    //   184: athrow
    //   185: astore 4
    //   187: new 43	org/apache/http/client/ClientProtocolException
    //   190: dup
    //   191: aload 4
    //   193: invokespecial 44	org/apache/http/client/ClientProtocolException:<init>	(Ljava/lang/Throwable;)V
    //   196: athrow
    // Line number table:
    //   Java source line #150	-> byte code offset #0
    //   Java source line #152	-> byte code offset #17
    //   Java source line #153	-> byte code offset #24
    //   Java source line #155	-> byte code offset #40
    //   Java source line #157	-> byte code offset #50
    //   Java source line #158	-> byte code offset #63
    //   Java source line #160	-> byte code offset #79
    //   Java source line #161	-> byte code offset #92
    //   Java source line #162	-> byte code offset #110
    //   Java source line #163	-> byte code offset #119
    //   Java source line #164	-> byte code offset #128
    //   Java source line #166	-> byte code offset #137
    //   Java source line #167	-> byte code offset #140
    //   Java source line #168	-> byte code offset #142
    //   Java source line #169	-> byte code offset #152
    //   Java source line #170	-> byte code offset #155
    //   Java source line #171	-> byte code offset #157
    //   Java source line #172	-> byte code offset #167
    //   Java source line #173	-> byte code offset #170
    //   Java source line #174	-> byte code offset #172
    //   Java source line #175	-> byte code offset #182
    //   Java source line #177	-> byte code offset #185
    //   Java source line #178	-> byte code offset #187
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	197	0	this	DecompressingHttpClient
    //   0	197	1	target	HttpHost
    //   0	197	2	request	HttpRequest
    //   0	197	3	context	HttpContext
    //   15	81	4	localContext	HttpContext
    //   185	7	4	e	org.apache.http.HttpException
    //   35	3	5	wrapped	HttpRequest
    //   48	21	5	wrapped	HttpRequest
    //   77	96	6	response	HttpResponse
    //   140	13	7	ex	org.apache.http.HttpException
    //   155	13	7	ex	IOException
    //   170	13	7	ex	RuntimeException
    // Exception table:
    //   from	to	target	type
    //   79	139	140	org/apache/http/HttpException
    //   79	139	155	java/io/IOException
    //   79	139	170	java/lang/RuntimeException
    //   0	139	185	org/apache/http/HttpException
    //   140	185	185	org/apache/http/HttpException
  }
  
  public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler)
    throws IOException, ClientProtocolException
  {
    return (T)execute(getHttpHost(request), request, responseHandler);
  }
  
  public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context)
    throws IOException, ClientProtocolException
  {
    return (T)execute(getHttpHost(request), request, responseHandler, context);
  }
  
  public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler)
    throws IOException, ClientProtocolException
  {
    return (T)execute(target, request, responseHandler, null);
  }
  
  public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context)
    throws IOException, ClientProtocolException
  {
    HttpResponse response = execute(target, request, context);
    try
    {
      HttpEntity entity;
      return (T)responseHandler.handleResponse(response);
    }
    finally
    {
      HttpEntity entity = response.getEntity();
      if (entity != null) {
        EntityUtils.consume(entity);
      }
    }
  }
}

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

import java.net.ConnectException;
import java.net.SocketTimeoutException;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ConnectionBackoffStrategy;

public class DefaultBackoffStrategy
  implements ConnectionBackoffStrategy
{
  public boolean shouldBackoff(Throwable t)
  {
    return ((t instanceof SocketTimeoutException)) || ((t instanceof ConnectException));
  }
  
  public boolean shouldBackoff(HttpResponse resp)
  {
    return resp.getStatusLine().getStatusCode() == 503;
  }
}

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

import org.apache.http.HeaderElement;
import org.apache.http.HeaderElementIterator;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.message.BasicHeaderElementIterator;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class DefaultConnectionKeepAliveStrategy
  implements ConnectionKeepAliveStrategy
{
  public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
  
  public long getKeepAliveDuration(HttpResponse response, HttpContext context)
  {
    Args.notNull(response, "HTTP response");
    HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator("Keep-Alive"));
    while (it.hasNext())
    {
      HeaderElement he = it.nextElement();
      String param = he.getName();
      String value = he.getValue();
      if ((value != null) && (param.equalsIgnoreCase("timeout"))) {
        try
        {
          return Long.parseLong(value) * 1000L;
        }
        catch (NumberFormatException ignore) {}
      }
    }
    return -1L;
  }
}

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

import java.nio.charset.Charset;
import org.apache.http.HttpVersion;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.client.protocol.RequestAddCookies;
import org.apache.http.client.protocol.RequestAuthCache;
import org.apache.http.client.protocol.RequestClientConnControl;
import org.apache.http.client.protocol.RequestDefaultHeaders;
import org.apache.http.client.protocol.RequestProxyAuthentication;
import org.apache.http.client.protocol.RequestTargetAuthentication;
import org.apache.http.client.protocol.ResponseProcessCookies;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.params.SyncBasicHttpParams;
import org.apache.http.protocol.BasicHttpProcessor;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.RequestContent;
import org.apache.http.protocol.RequestExpectContinue;
import org.apache.http.protocol.RequestTargetHost;
import org.apache.http.protocol.RequestUserAgent;
import org.apache.http.util.VersionInfo;

@Deprecated
@ThreadSafe
public class DefaultHttpClient
  extends AbstractHttpClient
{
  public DefaultHttpClient(ClientConnectionManager conman, HttpParams params)
  {
    super(conman, params);
  }
  
  public DefaultHttpClient(ClientConnectionManager conman)
  {
    super(conman, null);
  }
  
  public DefaultHttpClient(HttpParams params)
  {
    super(null, params);
  }
  
  public DefaultHttpClient()
  {
    super(null, null);
  }
  
  protected HttpParams createHttpParams()
  {
    HttpParams params = new SyncBasicHttpParams();
    setDefaultHttpParams(params);
    return params;
  }
  
  public static void setDefaultHttpParams(HttpParams params)
  {
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);
    
    VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", DefaultHttpClient.class.getClassLoader());
    
    String release = vi != null ? vi.getRelease() : "UNAVAILABLE";
    
    HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.5)");
  }
  
  protected BasicHttpProcessor createHttpProcessor()
  {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
  }
}

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

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ConnectException;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.net.ssl.SSLException;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class DefaultHttpRequestRetryHandler
  implements HttpRequestRetryHandler
{
  public static final DefaultHttpRequestRetryHandler INSTANCE = new DefaultHttpRequestRetryHandler();
  private final int retryCount;
  private final boolean requestSentRetryEnabled;
  private final Set<Class<? extends IOException>> nonRetriableClasses;
  
  protected DefaultHttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled, Collection<Class<? extends IOException>> clazzes)
  {
    this.retryCount = retryCount;
    this.requestSentRetryEnabled = requestSentRetryEnabled;
    nonRetriableClasses = new HashSet();
    for (Class<? extends IOException> clazz : clazzes) {
      nonRetriableClasses.add(clazz);
    }
  }
  
  public DefaultHttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled)
  {
    this(retryCount, requestSentRetryEnabled, Arrays.asList(new Class[] { InterruptedIOException.class, UnknownHostException.class, ConnectException.class, SSLException.class }));
  }
  
  public DefaultHttpRequestRetryHandler()
  {
    this(3, false);
  }
  
  public boolean retryRequest(IOException exception, int executionCount, HttpContext context)
  {
    Args.notNull(exception, "Exception parameter");
    Args.notNull(context, "HTTP context");
    if (executionCount > retryCount) {
      return false;
    }
    if (nonRetriableClasses.contains(exception.getClass())) {
      return false;
    }
    for (Class<? extends IOException> rejectException : nonRetriableClasses) {
      if (rejectException.isInstance(exception)) {
        return false;
      }
    }
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    HttpRequest request = clientContext.getRequest();
    if (requestIsAborted(request)) {
      return false;
    }
    if (handleAsIdempotent(request)) {
      return true;
    }
    if ((!clientContext.isRequestSent()) || (requestSentRetryEnabled)) {
      return true;
    }
    return false;
  }
  
  public boolean isRequestSentRetryEnabled()
  {
    return requestSentRetryEnabled;
  }
  
  public int getRetryCount()
  {
    return retryCount;
  }
  
  protected boolean handleAsIdempotent(HttpRequest request)
  {
    return !(request instanceof HttpEntityEnclosingRequest);
  }
  
  @Deprecated
  protected boolean requestIsAborted(HttpRequest request)
  {
    HttpRequest req = request;
    if ((request instanceof RequestWrapper)) {
      req = ((RequestWrapper)request).getOriginal();
    }
    return ((req instanceof HttpUriRequest)) && (((HttpUriRequest)req).isAborted());
  }
}

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

import java.util.List;
import java.util.Map;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Deprecated
@Immutable
public class DefaultProxyAuthenticationHandler
  extends AbstractAuthenticationHandler
{
  public boolean isAuthenticationRequested(HttpResponse response, HttpContext context)
  {
    Args.notNull(response, "HTTP response");
    int status = response.getStatusLine().getStatusCode();
    return status == 407;
  }
  
  public Map<String, Header> getChallenges(HttpResponse response, HttpContext context)
    throws MalformedChallengeException
  {
    Args.notNull(response, "HTTP response");
    Header[] headers = response.getHeaders("Proxy-Authenticate");
    return parseChallenges(headers);
  }
  
  protected List<String> getAuthPreferences(HttpResponse response, HttpContext context)
  {
    List<String> authpref = (List)response.getParams().getParameter("http.auth.proxy-scheme-pref");
    if (authpref != null) {
      return authpref;
    }
    return super.getAuthPreferences(response, context);
  }
}

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

import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
import org.apache.http.RequestLine;
import org.apache.http.StatusLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.CircularRedirectException;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.utils.URIUtils;
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
@Immutable
public class DefaultRedirectHandler
  implements RedirectHandler
{
  private final Log log = LogFactory.getLog(getClass());
  private static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
  
  public boolean isRedirectRequested(HttpResponse response, HttpContext context)
  {
    Args.notNull(response, "HTTP response");
    
    int statusCode = response.getStatusLine().getStatusCode();
    switch (statusCode)
    {
    case 301: 
    case 302: 
    case 307: 
      HttpRequest request = (HttpRequest)context.getAttribute("http.request");
      
      String method = request.getRequestLine().getMethod();
      return (method.equalsIgnoreCase("GET")) || (method.equalsIgnoreCase("HEAD"));
    case 303: 
      return true;
    }
    return false;
  }
  
  public URI getLocationURI(HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    Args.notNull(response, "HTTP response");
    
    Header locationHeader = response.getFirstHeader("location");
    if (locationHeader == null) {
      throw new ProtocolException("Received redirect response " + response.getStatusLine() + " but no location header");
    }
    String location = locationHeader.getValue();
    if (log.isDebugEnabled()) {
      log.debug("Redirect requested to location '" + location + "'");
    }
    URI uri;
    try
    {
      uri = new URI(location);
    }
    catch (URISyntaxException ex)
    {
      throw new ProtocolException("Invalid redirect URI: " + location, ex);
    }
    HttpParams params = response.getParams();
    if (!uri.isAbsolute())
    {
      if (params.isParameterTrue("http.protocol.reject-relative-redirect")) {
        throw new ProtocolException("Relative redirect location '" + uri + "' not allowed");
      }
      HttpHost target = (HttpHost)context.getAttribute("http.target_host");
      
      Asserts.notNull(target, "Target host");
      
      HttpRequest request = (HttpRequest)context.getAttribute("http.request");
      try
      {
        URI requestURI = new URI(request.getRequestLine().getUri());
        URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, true);
        uri = URIUtils.resolve(absoluteRequestURI, uri);
      }
      catch (URISyntaxException ex)
      {
        throw new ProtocolException(ex.getMessage(), ex);
      }
    }
    if (params.isParameterFalse("http.protocol.allow-circular-redirects"))
    {
      RedirectLocations redirectLocations = (RedirectLocations)context.getAttribute("http.protocol.redirect-locations");
      if (redirectLocations == null)
      {
        redirectLocations = new RedirectLocations();
        context.setAttribute("http.protocol.redirect-locations", redirectLocations);
      }
      URI redirectURI;
      if (uri.getFragment() != null) {
        try
        {
          HttpHost target = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
          
          redirectURI = URIUtils.rewriteURI(uri, target, true);
        }
        catch (URISyntaxException ex)
        {
          throw new ProtocolException(ex.getMessage(), ex);
        }
      } else {
        redirectURI = uri;
      }
      if (redirectLocations.contains(redirectURI)) {
        throw new CircularRedirectException("Circular redirect to '" + redirectURI + "'");
      }
      redirectLocations.add(redirectURI);
    }
    return uri;
  }
}

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

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
import org.apache.http.RequestLine;
import org.apache.http.StatusLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.CircularRedirectException;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;
import org.apache.http.util.TextUtils;

@Immutable
public class DefaultRedirectStrategy
  implements RedirectStrategy
{
  private final Log log = LogFactory.getLog(getClass());
  @Deprecated
  public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
  public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectStrategy();
  private static final String[] REDIRECT_METHODS = { "GET", "HEAD" };
  
  public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(response, "HTTP response");
    
    int statusCode = response.getStatusLine().getStatusCode();
    String method = request.getRequestLine().getMethod();
    Header locationHeader = response.getFirstHeader("location");
    switch (statusCode)
    {
    case 302: 
      return (isRedirectable(method)) && (locationHeader != null);
    case 301: 
    case 307: 
      return isRedirectable(method);
    case 303: 
      return true;
    }
    return false;
  }
  
  public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(response, "HTTP response");
    Args.notNull(context, "HTTP context");
    
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    
    Header locationHeader = response.getFirstHeader("location");
    if (locationHeader == null) {
      throw new ProtocolException("Received redirect response " + response.getStatusLine() + " but no location header");
    }
    String location = locationHeader.getValue();
    if (log.isDebugEnabled()) {
      log.debug("Redirect requested to location '" + location + "'");
    }
    RequestConfig config = clientContext.getRequestConfig();
    
    URI uri = createLocationURI(location);
    try
    {
      if (!uri.isAbsolute())
      {
        if (!config.isRelativeRedirectsAllowed()) {
          throw new ProtocolException("Relative redirect location '" + uri + "' not allowed");
        }
        HttpHost target = clientContext.getTargetHost();
        Asserts.notNull(target, "Target host");
        URI requestURI = new URI(request.getRequestLine().getUri());
        URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, false);
        uri = URIUtils.resolve(absoluteRequestURI, uri);
      }
    }
    catch (URISyntaxException ex)
    {
      throw new ProtocolException(ex.getMessage(), ex);
    }
    RedirectLocations redirectLocations = (RedirectLocations)clientContext.getAttribute("http.protocol.redirect-locations");
    if (redirectLocations == null)
    {
      redirectLocations = new RedirectLocations();
      context.setAttribute("http.protocol.redirect-locations", redirectLocations);
    }
    if ((!config.isCircularRedirectsAllowed()) && 
      (redirectLocations.contains(uri))) {
      throw new CircularRedirectException("Circular redirect to '" + uri + "'");
    }
    redirectLocations.add(uri);
    return uri;
  }
  
  protected URI createLocationURI(String location)
    throws ProtocolException
  {
    try
    {
      URIBuilder b = new URIBuilder(new URI(location).normalize());
      String host = b.getHost();
      if (host != null) {
        b.setHost(host.toLowerCase(Locale.US));
      }
      String path = b.getPath();
      if (TextUtils.isEmpty(path)) {
        b.setPath("/");
      }
      return b.build();
    }
    catch (URISyntaxException ex)
    {
      throw new ProtocolException("Invalid redirect URI: " + location, ex);
    }
  }
  
  protected boolean isRedirectable(String method)
  {
    for (String m : REDIRECT_METHODS) {
      if (m.equalsIgnoreCase(method)) {
        return true;
      }
    }
    return false;
  }
  
  public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    URI uri = getLocationURI(request, response, context);
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("HEAD")) {
      return new HttpHead(uri);
    }
    if (method.equalsIgnoreCase("GET")) {
      return new HttpGet(uri);
    }
    int status = response.getStatusLine().getStatusCode();
    if (status == 307) {
      return RequestBuilder.copy(request).setUri(uri).build();
    }
    return new HttpGet(uri);
  }
}

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

import java.net.URI;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.protocol.HttpContext;

@Deprecated
@Immutable
class DefaultRedirectStrategyAdaptor
  implements RedirectStrategy
{
  private final RedirectHandler handler;
  
  public DefaultRedirectStrategyAdaptor(RedirectHandler handler)
  {
    this.handler = handler;
  }
  
  public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    return handler.isRedirectRequested(response, context);
  }
  
  public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
    throws ProtocolException
  {
    URI uri = handler.getLocationURI(response, context);
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("HEAD")) {
      return new HttpHead(uri);
    }
    return new HttpGet(uri);
  }
  
  public RedirectHandler getHandler()
  {
    return handler;
  }
}

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

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.ConnectionReuseStrategy;
import org.apache.http.HttpEntity;
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.ProtocolException;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.StatusLine;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthenticationHandler;
import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.NonRepeatableRequestException;
import org.apache.http.client.RedirectException;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.RequestDirector;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.methods.AbortableHttpRequest;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.conn.BasicManagedEntity;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionRequest;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.routing.BasicRouteDirector;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRouteDirector;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.conn.ConnectionShutdownException;
import org.apache.http.message.BasicHttpRequest;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
import org.apache.http.protocol.HttpRequestExecutor;
import org.apache.http.util.Args;
import org.apache.http.util.EntityUtils;

@Deprecated
@NotThreadSafe
public class DefaultRequestDirector
  implements RequestDirector
{
  private final Log log;
  protected final ClientConnectionManager connManager;
  protected final HttpRoutePlanner routePlanner;
  protected final ConnectionReuseStrategy reuseStrategy;
  protected final ConnectionKeepAliveStrategy keepAliveStrategy;
  protected final HttpRequestExecutor requestExec;
  protected final HttpProcessor httpProcessor;
  protected final HttpRequestRetryHandler retryHandler;
  @Deprecated
  protected final RedirectHandler redirectHandler;
  protected final RedirectStrategy redirectStrategy;
  @Deprecated
  protected final AuthenticationHandler targetAuthHandler;
  protected final AuthenticationStrategy targetAuthStrategy;
  @Deprecated
  protected final AuthenticationHandler proxyAuthHandler;
  protected final AuthenticationStrategy proxyAuthStrategy;
  protected final UserTokenHandler userTokenHandler;
  protected final HttpParams params;
  protected ManagedClientConnection managedConn;
  protected final AuthState targetAuthState;
  protected final AuthState proxyAuthState;
  private final HttpAuthenticator authenticator;
  private int execCount;
  private int redirectCount;
  private final int maxRedirects;
  private HttpHost virtualHost;
  
  @Deprecated
  public DefaultRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
  {
    this(LogFactory.getLog(DefaultRequestDirector.class), requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler, new DefaultRedirectStrategyAdaptor(redirectHandler), new AuthenticationStrategyAdaptor(targetAuthHandler), new AuthenticationStrategyAdaptor(proxyAuthHandler), userTokenHandler, params);
  }
  
  @Deprecated
  public DefaultRequestDirector(Log log, HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params)
  {
    this(LogFactory.getLog(DefaultRequestDirector.class), requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler, redirectStrategy, new AuthenticationStrategyAdaptor(targetAuthHandler), new AuthenticationStrategyAdaptor(proxyAuthHandler), userTokenHandler, params);
  }
  
  public DefaultRequestDirector(Log log, HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectStrategy redirectStrategy, AuthenticationStrategy targetAuthStrategy, AuthenticationStrategy proxyAuthStrategy, UserTokenHandler userTokenHandler, HttpParams params)
  {
    Args.notNull(log, "Log");
    Args.notNull(requestExec, "Request executor");
    Args.notNull(conman, "Client connection manager");
    Args.notNull(reustrat, "Connection reuse strategy");
    Args.notNull(kastrat, "Connection keep alive strategy");
    Args.notNull(rouplan, "Route planner");
    Args.notNull(httpProcessor, "HTTP protocol processor");
    Args.notNull(retryHandler, "HTTP request retry handler");
    Args.notNull(redirectStrategy, "Redirect strategy");
    Args.notNull(targetAuthStrategy, "Target authentication strategy");
    Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
    Args.notNull(userTokenHandler, "User token handler");
    Args.notNull(params, "HTTP parameters");
    this.log = log;
    authenticator = new HttpAuthenticator(log);
    this.requestExec = requestExec;
    connManager = conman;
    reuseStrategy = reustrat;
    keepAliveStrategy = kastrat;
    routePlanner = rouplan;
    this.httpProcessor = httpProcessor;
    this.retryHandler = retryHandler;
    this.redirectStrategy = redirectStrategy;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy = proxyAuthStrategy;
    this.userTokenHandler = userTokenHandler;
    this.params = params;
    if ((redirectStrategy instanceof DefaultRedirectStrategyAdaptor)) {
      redirectHandler = ((DefaultRedirectStrategyAdaptor)redirectStrategy).getHandler();
    } else {
      redirectHandler = null;
    }
    if ((targetAuthStrategy instanceof AuthenticationStrategyAdaptor)) {
      targetAuthHandler = ((AuthenticationStrategyAdaptor)targetAuthStrategy).getHandler();
    } else {
      targetAuthHandler = null;
    }
    if ((proxyAuthStrategy instanceof AuthenticationStrategyAdaptor)) {
      proxyAuthHandler = ((AuthenticationStrategyAdaptor)proxyAuthStrategy).getHandler();
    } else {
      proxyAuthHandler = null;
    }
    managedConn = null;
    
    execCount = 0;
    redirectCount = 0;
    targetAuthState = new AuthState();
    proxyAuthState = new AuthState();
    maxRedirects = this.params.getIntParameter("http.protocol.max-redirects", 100);
  }
  
  private RequestWrapper wrapRequest(HttpRequest request)
    throws ProtocolException
  {
    if ((request instanceof HttpEntityEnclosingRequest)) {
      return new EntityEnclosingRequestWrapper((HttpEntityEnclosingRequest)request);
    }
    return new RequestWrapper(request);
  }
  
  protected void rewriteRequestURI(RequestWrapper request, HttpRoute route)
    throws ProtocolException
  {
    try
    {
      URI uri = request.getURI();
      if ((route.getProxyHost() != null) && (!route.isTunnelled()))
      {
        if (!uri.isAbsolute())
        {
          HttpHost target = route.getTargetHost();
          uri = URIUtils.rewriteURI(uri, target, true);
        }
        else
        {
          uri = URIUtils.rewriteURI(uri);
        }
      }
      else if (uri.isAbsolute()) {
        uri = URIUtils.rewriteURI(uri, null, true);
      } else {
        uri = URIUtils.rewriteURI(uri);
      }
      request.setURI(uri);
    }
    catch (URISyntaxException ex)
    {
      throw new ProtocolException("Invalid URI: " + request.getRequestLine().getUri(), ex);
    }
  }
  
  public HttpResponse execute(HttpHost targetHost, HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    context.setAttribute("http.auth.target-scope", targetAuthState);
    context.setAttribute("http.auth.proxy-scope", proxyAuthState);
    
    HttpHost target = targetHost;
    
    HttpRequest orig = request;
    RequestWrapper origWrapper = wrapRequest(orig);
    origWrapper.setParams(params);
    HttpRoute origRoute = determineRoute(target, origWrapper, context);
    
    virtualHost = ((HttpHost)origWrapper.getParams().getParameter("http.virtual-host"));
    if ((virtualHost != null) && (virtualHost.getPort() == -1))
    {
      HttpHost host = target != null ? target : origRoute.getTargetHost();
      int port = host.getPort();
      if (port != -1) {
        virtualHost = new HttpHost(virtualHost.getHostName(), port, virtualHost.getSchemeName());
      }
    }
    RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
    
    boolean reuse = false;
    boolean done = false;
    try
    {
      HttpResponse response = null;
      while (!done)
      {
        RequestWrapper wrapper = roureq.getRequest();
        HttpRoute route = roureq.getRoute();
        response = null;
        
        Object userToken = context.getAttribute("http.user-token");
        if (managedConn == null)
        {
          ClientConnectionRequest connRequest = connManager.requestConnection(route, userToken);
          if ((orig instanceof AbortableHttpRequest)) {
            ((AbortableHttpRequest)orig).setConnectionRequest(connRequest);
          }
          long timeout = HttpClientParams.getConnectionManagerTimeout(params);
          try
          {
            managedConn = connRequest.getConnection(timeout, TimeUnit.MILLISECONDS);
          }
          catch (InterruptedException interrupted)
          {
            Thread.currentThread().interrupt();
            throw new InterruptedIOException();
          }
          if (HttpConnectionParams.isStaleCheckingEnabled(params)) {
            if (managedConn.isOpen())
            {
              log.debug("Stale connection check");
              if (managedConn.isStale())
              {
                log.debug("Stale connection detected");
                managedConn.close();
              }
            }
          }
        }
        if ((orig instanceof AbortableHttpRequest)) {
          ((AbortableHttpRequest)orig).setReleaseTrigger(managedConn);
        }
        try
        {
          tryConnect(roureq, context);
        }
        catch (TunnelRefusedException ex)
        {
          if (log.isDebugEnabled()) {
            log.debug(ex.getMessage());
          }
          response = ex.getResponse();
          break;
        }
        String userinfo = wrapper.getURI().getUserInfo();
        if (userinfo != null) {
          targetAuthState.update(new BasicScheme(), new UsernamePasswordCredentials(userinfo));
        }
        if (virtualHost != null)
        {
          target = virtualHost;
        }
        else
        {
          URI requestURI = wrapper.getURI();
          if (requestURI.is
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