java学习基地

微信扫一扫 分享朋友圈

已有 366 人浏览分享

有人帮忙看下这个base64 解密表是什么吗 可付支付宝

[复制链接]
366 0
package nbc;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.security.AccessController;
import java.security.GeneralSecurityException;
import java.security.PrivilegedAction;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class HttpRequest
{
  private static final String BOUNDARY = "00content0boundary00";
  public static final String CHARSET_UTF8 = "UTF-8";
  private static ConnectionFactory CONNECTION_FACTORY = ConnectionFactory.DEFAULT;
  public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
  public static final String CONTENT_TYPE_JSON = "application/json";
  private static final String CONTENT_TYPE_MULTIPART = "multipart/form-data; boundary=00content0boundary00";
  private static final String CRLF = "\r\n";
  private static final String[] EMPTY_STRINGS = new String[0];
  public static final String ENCODING_GZIP = "gzip";
  public static final String HEADER_ACCEPT = "Accept";
  public static final String HEADER_ACCEPT_CHARSET = "Accept-Charset";
  public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
  public static final String HEADER_AUTHORIZATION = "Authorization";
  public static final String HEADER_CACHE_CONTROL = "Cache-Control";
  public static final String HEADER_CONTENT_ENCODING = "Content-Encoding";
  public static final String HEADER_CONTENT_LENGTH = "Content-Length";
  public static final String HEADER_CONTENT_TYPE = "Content-Type";
  public static final String HEADER_DATE = "Date";
  public static final String HEADER_ETAG = "ETag";
  public static final String HEADER_EXPIRES = "Expires";
  public static final String HEADER_IF_NONE_MATCH = "If-None-Match";
  public static final String HEADER_LAST_MODIFIED = "Last-Modified";
  public static final String HEADER_LOCATION = "Location";
  public static final String HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization";
  public static final String HEADER_REFERER = "Referer";
  public static final String HEADER_SERVER = "Server";
  public static final String HEADER_USER_AGENT = "User-Agent";
  public static final String METHOD_DELETE = "DELETE";
  public static final String METHOD_GET = "GET";
  public static final String METHOD_HEAD = "HEAD";
  public static final String METHOD_OPTIONS = "OPTIONS";
  public static final String METHOD_POST = "POST";
  public static final String METHOD_PUT = "PUT";
  public static final String METHOD_TRACE = "TRACE";
  public static final String PARAM_CHARSET = "charset";
  private static SSLSocketFactory TRUSTED_FACTORY;
  private static HostnameVerifier TRUSTED_VERIFIER;
  private int bufferSize = 8192;
  private HttpURLConnection connection = null;
  private boolean form;
  private String httpProxyHost;
  private int httpProxyPort;
  private boolean ignoreCloseExceptions = true;
  private boolean multipart;
  private RequestOutputStream output;
  private UploadProgress progress = UploadProgress.DEFAULT;
  private final String requestMethod;
  private long totalSize = -1L;
  private long totalWritten = 0L;
  private boolean uncompress = false;
  private final URL url;

  public HttpRequest(CharSequence paramCharSequence, String paramString)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      this.url = new URL(paramCharSequence.toString());
      this.requestMethod = paramString;
      return;
    }
    catch (MalformedURLException paramCharSequence)
    {
      throw new HttpRequestException(paramCharSequence);
    }
  }

  public HttpRequest(URL paramURL, String paramString)
    throws HttpRequest.HttpRequestException
  {
    this.url = paramURL;
    this.requestMethod = paramString;
  }

  private static StringBuilder addParam(Object paramObject1, Object paramObject2, StringBuilder paramStringBuilder)
  {
    Object localObject = paramObject2;
    if (paramObject2 != null)
    {
      localObject = paramObject2;
      if (paramObject2.getClass().isArray()) {
        localObject = arrayToList(paramObject2);
      }
    }
    if ((localObject instanceof Iterable))
    {
      paramObject2 = ((Iterable)localObject).iterator();
      if (((Iterator)paramObject2).hasNext()) {}
    }
    do
    {
      return paramStringBuilder;
      paramStringBuilder.append(paramObject1);
      paramStringBuilder.append("[]=");
      localObject = ((Iterator)paramObject2).next();
      if (localObject != null) {
        paramStringBuilder.append(localObject);
      }
      if (!((Iterator)paramObject2).hasNext()) {
        break;
      }
      paramStringBuilder.append("&");
      break;
      paramStringBuilder.append(paramObject1);
      paramStringBuilder.append("=");
    } while (localObject == null);
    paramStringBuilder.append(localObject);
    return paramStringBuilder;
  }

  private static StringBuilder addParamPrefix(String paramString, StringBuilder paramStringBuilder)
  {
    int i = paramString.indexOf('?');
    int j = paramStringBuilder.length() - 1;
    if (i == -1) {
      paramStringBuilder.append('?');
    }
    while ((i >= j) || (paramString.charAt(j) == '&')) {
      return paramStringBuilder;
    }
    paramStringBuilder.append('&');
    return paramStringBuilder;
  }

  private static StringBuilder addPathSeparator(String paramString, StringBuilder paramStringBuilder)
  {
    if (paramString.indexOf(':') + 2 == paramString.lastIndexOf('/')) {
      paramStringBuilder.append('/');
    }
    return paramStringBuilder;
  }

  public static String append(CharSequence paramCharSequence, Map<?, ?> paramMap)
  {
    Object localObject = paramCharSequence.toString();
    if ((paramMap == null) || (paramMap.isEmpty())) {
      return (String)localObject;
    }
    paramCharSequence = new StringBuilder((String)localObject);
    addPathSeparator((String)localObject, paramCharSequence);
    addParamPrefix((String)localObject, paramCharSequence);
    paramMap = paramMap.entrySet().iterator();
    localObject = (Map.Entry)paramMap.next();
    addParam(((Map.Entry)localObject).getKey().toString(), ((Map.Entry)localObject).getValue(), paramCharSequence);
    for (;;)
    {
      if (!paramMap.hasNext()) {
        return paramCharSequence.toString();
      }
      paramCharSequence.append('&');
      localObject = (Map.Entry)paramMap.next();
      addParam(((Map.Entry)localObject).getKey().toString(), ((Map.Entry)localObject).getValue(), paramCharSequence);
    }
  }

  public static String append(CharSequence paramCharSequence, Object... paramVarArgs)
  {
    paramCharSequence = paramCharSequence.toString();
    if ((paramVarArgs == null) || (paramVarArgs.length == 0)) {
      return paramCharSequence;
    }
    if (paramVarArgs.length % 2 != 0) {
      throw new IllegalArgumentException("Must specify an even number of parameter names/values");
    }
    StringBuilder localStringBuilder = new StringBuilder(paramCharSequence);
    addPathSeparator(paramCharSequence, localStringBuilder);
    addParamPrefix(paramCharSequence, localStringBuilder);
    addParam(paramVarArgs[0], paramVarArgs[1], localStringBuilder);
    int i = 2;
    for (;;)
    {
      if (i >= paramVarArgs.length) {
        return localStringBuilder.toString();
      }
      localStringBuilder.append('&');
      addParam(paramVarArgs, paramVarArgs[(i + 1)], localStringBuilder);
      i += 2;
    }
  }

  private static List<Object> arrayToList(Object paramObject)
  {
    int j = 0;
    int k = 0;
    int m = 0;
    int n = 0;
    int i1 = 0;
    int i2 = 0;
    int i3 = 0;
    int i = 0;
    Object localObject;
    if ((paramObject instanceof Object[])) {
      localObject = Arrays.asList((Object[])paramObject);
    }
    ArrayList localArrayList;
    do
    {
      return (List<Object>)localObject;
      localArrayList = new ArrayList();
      if ((paramObject instanceof int[]))
      {
        paramObject = (int[])paramObject;
        j = paramObject.length;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Integer.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof boolean[]))
      {
        paramObject = (boolean[])paramObject;
        k = paramObject.length;
        i = j;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= k) {
            break;
          }
          localArrayList.add(Boolean.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof long[]))
      {
        paramObject = (long[])paramObject;
        j = paramObject.length;
        i = k;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Long.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof float[]))
      {
        paramObject = (float[])paramObject;
        j = paramObject.length;
        i = m;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Float.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof double[]))
      {
        paramObject = (double[])paramObject;
        j = paramObject.length;
        i = n;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Double.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof short[]))
      {
        paramObject = (short[])paramObject;
        j = paramObject.length;
        i = i1;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Short.valueOf(paramObject));
          i += 1;
        }
      }
      if ((paramObject instanceof byte[]))
      {
        paramObject = (byte[])paramObject;
        j = paramObject.length;
        i = i2;
        for (;;)
        {
          localObject = localArrayList;
          if (i >= j) {
            break;
          }
          localArrayList.add(Byte.valueOf(paramObject));
          i += 1;
        }
      }
      localObject = localArrayList;
    } while (!(paramObject instanceof char[]));
    paramObject = (char[])paramObject;
    j = paramObject.length;
    i = i3;
    for (;;)
    {
      localObject = localArrayList;
      if (i >= j) {
        break;
      }
      localArrayList.add(Character.valueOf(paramObject));
      i += 1;
    }
  }

  /* Error */
  private HttpURLConnection createConnection()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 437        com/yaag/timelimit/HttpRequest:httpProxyHost        Ljava/lang/String;
    //   4: ifnull +30 -> 34
    //   7: getstatic 192        com/yaag/timelimit/HttpRequest:CONNECTION_FACTORY        Lcom/yaag/timelimit/HttpRequest$ConnectionFactory;
    //   10: aload_0
    //   11: getfield 230        com/yaag/timelimit/HttpRequest:url        Ljava/net/URL;
    //   14: aload_0
    //   15: invokespecial 441        com/yaag/timelimit/HttpRequest:createProxy        ()Ljava/net/Proxy;
    //   18: invokeinterface 445 3 0
    //   23: astore_1
    //   24: aload_1
    //   25: aload_0
    //   26: getfield 232        com/yaag/timelimit/HttpRequest:requestMethod        Ljava/lang/String;
    //   29: invokevirtual 450        java/net/HttpURLConnection:setRequestMethod        (Ljava/lang/String;)V
    //   32: aload_1
    //   33: areturn
    //   34: getstatic 192        com/yaag/timelimit/HttpRequest:CONNECTION_FACTORY        Lcom/yaag/timelimit/HttpRequest$ConnectionFactory;
    //   37: aload_0
    //   38: getfield 230        com/yaag/timelimit/HttpRequest:url        Ljava/net/URL;
    //   41: invokeinterface 453 2 0
    //   46: astore_1
    //   47: goto -23 -> 24
    //   50: astore_1
    //   51: new 40        com/yaag/timelimit/HttpRequest$HttpRequestException
    //   54: dup
    //   55: aload_1
    //   56: invokespecial 235        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
    //   59: athrow
    // Local variable table:
    //   start        length        slot        name        signature
    //   0        60        0        this        HttpRequest
    //   23        24        1        localHttpURLConnection        HttpURLConnection
    //   50        6        1        localIOException        IOException
    // Exception table:
    //   from        to        target        type
    //   0        24        50        java/io/IOException
    //   24        32        50        java/io/IOException
    //   34        47        50        java/io/IOException
  }

  private Proxy createProxy()
  {
    return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(this.httpProxyHost, this.httpProxyPort));
  }

  public static HttpRequest delete(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "DELETE");
  }

  public static HttpRequest delete(CharSequence paramCharSequence, Map<?, ?> paramMap, boolean paramBoolean)
  {
    paramMap = append(paramCharSequence, paramMap);
    paramCharSequence = paramMap;
    if (paramBoolean) {
      paramCharSequence = encode(paramMap);
    }
    return delete(paramCharSequence);
  }

  public static HttpRequest delete(CharSequence paramCharSequence, boolean paramBoolean, Object... paramVarArgs)
  {
    paramVarArgs = append(paramCharSequence, paramVarArgs);
    paramCharSequence = paramVarArgs;
    if (paramBoolean) {
      paramCharSequence = encode(paramVarArgs);
    }
    return delete(paramCharSequence);
  }

  public static HttpRequest delete(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "DELETE");
  }

  /* Error */
  public static String encode(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    // Byte code:
    //   0: new 219        java/net/URL
    //   3: dup
    //   4: aload_0
    //   5: invokeinterface 225 1 0
    //   10: invokespecial 228        java/net/URL:<init>        (Ljava/lang/String;)V
    //   13: astore_2
    //   14: aload_2
    //   15: invokevirtual 496        java/net/URL:getHost        ()Ljava/lang/String;
    //   18: astore_1
    //   19: aload_2
    //   20: invokevirtual 499        java/net/URL:getPort        ()I
    //   23: istore_3
    //   24: aload_1
    //   25: astore_0
    //   26: iload_3
    //   27: iconst_m1
    //   28: if_icmpeq +30 -> 58
    //   31: new 280        java/lang/StringBuilder
    //   34: dup
    //   35: aload_1
    //   36: invokestatic 502        java/lang/String:valueOf        (Ljava/lang/Object;)Ljava/lang/String;
    //   39: invokespecial 325        java/lang/StringBuilder:<init>        (Ljava/lang/String;)V
    //   42: bipush 58
    //   44: invokevirtual 310        java/lang/StringBuilder:append        (C)Ljava/lang/StringBuilder;
    //   47: iload_3
    //   48: invokestatic 505        java/lang/Integer:toString        (I)Ljava/lang/String;
    //   51: invokevirtual 289        java/lang/StringBuilder:append        (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   54: invokevirtual 348        java/lang/StringBuilder:toString        ()Ljava/lang/String;
    //   57: astore_0
    //   58: new 507        java/net/URI
    //   61: dup
    //   62: aload_2
    //   63: invokevirtual 510        java/net/URL:getProtocol        ()Ljava/lang/String;
    //   66: aload_0
    //   67: aload_2
    //   68: invokevirtual 513        java/net/URL:getPath        ()Ljava/lang/String;
    //   71: aload_2
    //   72: invokevirtual 516        java/net/URL:getQuery        ()Ljava/lang/String;
    //   75: aconst_null
    //   76: invokespecial 519        java/net/URI:<init>        (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    //   79: invokevirtual 522        java/net/URI:toASCIIString        ()Ljava/lang/String;
    //   82: astore_1
    //   83: aload_1
    //   84: bipush 63
    //   86: invokevirtual 303        java/lang/String:indexOf        (I)I
    //   89: istore_3
    //   90: aload_1
    //   91: astore_0
    //   92: iload_3
    //   93: ifle +56 -> 149
    //   96: aload_1
    //   97: astore_0
    //   98: iload_3
    //   99: iconst_1
    //   100: iadd
    //   101: aload_1
    //   102: invokevirtual 523        java/lang/String:length        ()I
    //   105: if_icmpge +44 -> 149
    //   108: new 280        java/lang/StringBuilder
    //   111: dup
    //   112: aload_1
    //   113: iconst_0
    //   114: iload_3
    //   115: iconst_1
    //   116: iadd
    //   117: invokevirtual 527        java/lang/String:substring        (II)Ljava/lang/String;
    //   120: invokestatic 502        java/lang/String:valueOf        (Ljava/lang/Object;)Ljava/lang/String;
    //   123: invokespecial 325        java/lang/StringBuilder:<init>        (Ljava/lang/String;)V
    //   126: aload_1
    //   127: iload_3
    //   128: iconst_1
    //   129: iadd
    //   130: invokevirtual 529        java/lang/String:substring        (I)Ljava/lang/String;
    //   133: ldc_w 531
    //   136: ldc_w 533
    //   139: invokevirtual 537        java/lang/String:replace        (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
    //   142: invokevirtual 289        java/lang/StringBuilder:append        (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   145: invokevirtual 348        java/lang/StringBuilder:toString        ()Ljava/lang/String;
    //   148: astore_0
    //   149: aload_0
    //   150: areturn
    //   151: astore_0
    //   152: new 40        com/yaag/timelimit/HttpRequest$HttpRequestException
    //   155: dup
    //   156: aload_0
    //   157: invokespecial 235        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
    //   160: athrow
    //   161: astore_0
    //   162: new 435        java/io/IOException
    //   165: dup
    //   166: ldc_w 539
    //   169: invokespecial 540        java/io/IOException:<init>        (Ljava/lang/String;)V
    //   172: astore_1
    //   173: aload_1
    //   174: aload_0
    //   175: invokevirtual 544        java/io/IOException:initCause        (Ljava/lang/Throwable;)Ljava/lang/Throwable;
    //   178: pop
    //   179: new 40        com/yaag/timelimit/HttpRequest$HttpRequestException
    //   182: dup
    //   183: aload_1
    //   184: invokespecial 235        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
    //   187: athrow
    // Local variable table:
    //   start        length        slot        name        signature
    //   0        188        0        paramCharSequence        CharSequence
    //   18        166        1        localObject        Object
    //   13        59        2        localURL        URL
    //   23        107        3        i        int
    // Exception table:
    //   from        to        target        type
    //   0        14        151        java/io/IOException
    //   58        90        161        java/net/URISyntaxException
    //   98        149        161        java/net/URISyntaxException
  }

  public static HttpRequest get(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "GET");
  }

  public static HttpRequest get(CharSequence paramCharSequence, Map<?, ?> paramMap, boolean paramBoolean)
  {
    paramMap = append(paramCharSequence, paramMap);
    paramCharSequence = paramMap;
    if (paramBoolean) {
      paramCharSequence = encode(paramMap);
    }
    return get(paramCharSequence);
  }

  public static HttpRequest get(CharSequence paramCharSequence, boolean paramBoolean, Object... paramVarArgs)
  {
    paramVarArgs = append(paramCharSequence, paramVarArgs);
    paramCharSequence = paramVarArgs;
    if (paramBoolean) {
      paramCharSequence = encode(paramVarArgs);
    }
    return get(paramCharSequence);
  }

  public static HttpRequest get(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "GET");
  }

  private static SSLSocketFactory getTrustedFactory()
    throws HttpRequest.HttpRequestException
  {
    X509TrustManager local1;
    if (TRUSTED_FACTORY == null) {
      local1 = new X509TrustManager()
      {
        public void checkClientTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString) {}

        public void checkServerTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString) {}

        public X509Certificate[] getAcceptedIssuers()
        {
          return new X509Certificate[0];
        }
      };
    }
    try
    {
      localObject = SSLContext.getInstance("TLS");
      SecureRandom localSecureRandom = new SecureRandom();
      ((SSLContext)localObject).init(null, new TrustManager[] { local1 }, localSecureRandom);
      TRUSTED_FACTORY = ((SSLContext)localObject).getSocketFactory();
      return TRUSTED_FACTORY;
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      Object localObject = new IOException("Security exception configuring SSL context");
      ((IOException)localObject).initCause(localGeneralSecurityException);
      throw new HttpRequestException((IOException)localObject);
    }
  }

  private static HostnameVerifier getTrustedVerifier()
  {
    if (TRUSTED_VERIFIER == null) {
      TRUSTED_VERIFIER = new HostnameVerifier()
      {
        public boolean verify(String paramAnonymousString, SSLSession paramAnonymousSSLSession)
        {
          return true;
        }
      };
    }
    return TRUSTED_VERIFIER;
  }

  private static String getValidCharset(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0)) {
      return paramString;
    }
    return "UTF-8";
  }

  public static HttpRequest head(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "HEAD");
  }

  public static HttpRequest head(CharSequence paramCharSequence, Map<?, ?> paramMap, boolean paramBoolean)
  {
    paramMap = append(paramCharSequence, paramMap);
    paramCharSequence = paramMap;
    if (paramBoolean) {
      paramCharSequence = encode(paramMap);
    }
    return head(paramCharSequence);
  }

  public static HttpRequest head(CharSequence paramCharSequence, boolean paramBoolean, Object... paramVarArgs)
  {
    paramVarArgs = append(paramCharSequence, paramVarArgs);
    paramCharSequence = paramVarArgs;
    if (paramBoolean) {
      paramCharSequence = encode(paramVarArgs);
    }
    return head(paramCharSequence);
  }

  public static HttpRequest head(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "HEAD");
  }

  private HttpRequest incrementTotalSize(long paramLong)
  {
    if (this.totalSize == -1L) {
      this.totalSize = 0L;
    }
    this.totalSize += paramLong;
    return this;
  }

  public static void keepAlive(boolean paramBoolean)
  {
    setProperty("http.keepAlive", Boolean.toString(paramBoolean));
  }

  public static void maxConnections(int paramInt)
  {
    setProperty("http.maxConnections", Integer.toString(paramInt));
  }

  public static void nonProxyHosts(String... paramVarArgs)
  {
    if ((paramVarArgs != null) && (paramVarArgs.length > 0))
    {
      StringBuilder localStringBuilder = new StringBuilder();
      int j = paramVarArgs.length - 1;
      int i = 0;
      for (;;)
      {
        if (i >= j)
        {
          localStringBuilder.append(paramVarArgs[j]);
          setProperty("http.nonProxyHosts", localStringBuilder.toString());
          return;
        }
        localStringBuilder.append(paramVarArgs).append('|');
        i += 1;
      }
    }
    setProperty("http.nonProxyHosts", null);
  }

  public static HttpRequest options(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "OPTIONS");
  }

  public static HttpRequest options(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "OPTIONS");
  }

  public static HttpRequest post(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "POST");
  }

  public static HttpRequest post(CharSequence paramCharSequence, Map<?, ?> paramMap, boolean paramBoolean)
  {
    paramMap = append(paramCharSequence, paramMap);
    paramCharSequence = paramMap;
    if (paramBoolean) {
      paramCharSequence = encode(paramMap);
    }
    return post(paramCharSequence);
  }

  public static HttpRequest post(CharSequence paramCharSequence, boolean paramBoolean, Object... paramVarArgs)
  {
    paramVarArgs = append(paramCharSequence, paramVarArgs);
    paramCharSequence = paramVarArgs;
    if (paramBoolean) {
      paramCharSequence = encode(paramVarArgs);
    }
    return post(paramCharSequence);
  }

  public static HttpRequest post(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "POST");
  }

  public static void proxyHost(String paramString)
  {
    setProperty("http.proxyHost", paramString);
    setProperty("https.proxyHost", paramString);
  }

  public static void proxyPort(int paramInt)
  {
    String str = Integer.toString(paramInt);
    setProperty("http.proxyPort", str);
    setProperty("https.proxyPort", str);
  }

  public static HttpRequest put(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "PUT");
  }

  public static HttpRequest put(CharSequence paramCharSequence, Map<?, ?> paramMap, boolean paramBoolean)
  {
    paramMap = append(paramCharSequence, paramMap);
    paramCharSequence = paramMap;
    if (paramBoolean) {
      paramCharSequence = encode(paramMap);
    }
    return put(paramCharSequence);
  }

  public static HttpRequest put(CharSequence paramCharSequence, boolean paramBoolean, Object... paramVarArgs)
  {
    paramVarArgs = append(paramCharSequence, paramVarArgs);
    paramCharSequence = paramVarArgs;
    if (paramBoolean) {
      paramCharSequence = encode(paramVarArgs);
    }
    return put(paramCharSequence);
  }

  public static HttpRequest put(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "PUT");
  }

  public static void setConnectionFactory(ConnectionFactory paramConnectionFactory)
  {
    if (paramConnectionFactory == null)
    {
      CONNECTION_FACTORY = ConnectionFactory.DEFAULT;
      return;
    }
    CONNECTION_FACTORY = paramConnectionFactory;
  }

  private static String setProperty(String paramString1, final String paramString2)
  {
    if (paramString2 != null) {}
    for (paramString1 = new PrivilegedAction()
        {
          public String run()
          {
            return System.setProperty(HttpRequest.this, paramString2);
          }
        };; paramString1 = new PrivilegedAction()
        {
          public String run()
          {
            return System.clearProperty(HttpRequest.this);
          }
        }) {
      return (String)AccessController.doPrivileged(paramString1);
    }
  }

  public static HttpRequest trace(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramCharSequence, "TRACE");
  }

  public static HttpRequest trace(URL paramURL)
    throws HttpRequest.HttpRequestException
  {
    return new HttpRequest(paramURL, "TRACE");
  }

  public HttpRequest accept(String paramString)
  {
    return header("Accept", paramString);
  }

  public HttpRequest acceptCharset(String paramString)
  {
    return header("Accept-Charset", paramString);
  }

  public HttpRequest acceptEncoding(String paramString)
  {
    return header("Accept-Encoding", paramString);
  }

  public HttpRequest acceptGzipEncoding()
  {
    return acceptEncoding("gzip");
  }

  public HttpRequest acceptJson()
  {
    return accept("application/json");
  }

  public HttpRequest authorization(String paramString)
  {
    return header("Authorization", paramString);
  }

  public boolean badRequest()
    throws HttpRequest.HttpRequestException
  {
    return 400 == code();
  }

  public HttpRequest basic(String paramString1, String paramString2)
  {
    return authorization("Basic " + Base64.encode(new StringBuilder(String.valueOf(paramString1)).append(':').append(paramString2).toString()));
  }

  public HttpRequest body(AtomicReference<String> paramAtomicReference)
    throws HttpRequest.HttpRequestException
  {
    paramAtomicReference.set(body());
    return this;
  }

  public HttpRequest body(AtomicReference<String> paramAtomicReference, String paramString)
    throws HttpRequest.HttpRequestException
  {
    paramAtomicReference.set(body(paramString));
    return this;
  }

  public String body()
    throws HttpRequest.HttpRequestException
  {
    return body(charset());
  }

  public String body(String paramString)
    throws HttpRequest.HttpRequestException
  {
    ByteArrayOutputStream localByteArrayOutputStream = byteStream();
    try
    {
      copy(buffer(), localByteArrayOutputStream);
      paramString = localByteArrayOutputStream.toString(getValidCharset(paramString));
      return paramString;
    }
    catch (IOException paramString)
    {
      throw new HttpRequestException(paramString);
    }
  }

  public BufferedInputStream buffer()
    throws HttpRequest.HttpRequestException
  {
    return new BufferedInputStream(stream(), this.bufferSize);
  }

  public int bufferSize()
  {
    return this.bufferSize;
  }

  public HttpRequest bufferSize(int paramInt)
  {
    if (paramInt < 1) {
      throw new IllegalArgumentException("Size must be greater than zero");
    }
    this.bufferSize = paramInt;
    return this;
  }

  public BufferedReader bufferedReader()
    throws HttpRequest.HttpRequestException
  {
    return bufferedReader(charset());
  }

  public BufferedReader bufferedReader(String paramString)
    throws HttpRequest.HttpRequestException
  {
    return new BufferedReader(reader(paramString), this.bufferSize);
  }

  protected ByteArrayOutputStream byteStream()
  {
    int i = contentLength();
    if (i > 0) {
      return new ByteArrayOutputStream(i);
    }
    return new ByteArrayOutputStream();
  }

  public byte[] bytes()
    throws HttpRequest.HttpRequestException
  {
    ByteArrayOutputStream localByteArrayOutputStream = byteStream();
    try
    {
      copy(buffer(), localByteArrayOutputStream);
      return localByteArrayOutputStream.toByteArray();
    }
    catch (IOException localIOException)
    {
      throw new HttpRequestException(localIOException);
    }
  }

  public String cacheControl()
  {
    return header("Cache-Control");
  }

  public String charset()
  {
    return parameter("Content-Type", "charset");
  }

  public HttpRequest chunk(int paramInt)
  {
    getConnection().setChunkedStreamingMode(paramInt);
    return this;
  }

  protected HttpRequest closeOutput()
    throws IOException
  {
    progress(null);
    if (this.output == null) {
      return this;
    }
    if (this.multipart) {
      this.output.write("\r\n--00content0boundary00--\r\n");
    }
    if (this.ignoreCloseExceptions) {}
    try
    {
      this.output.close();
      for (;;)
      {
        this.output = null;
        return this;
        this.output.close();
      }
    }
    catch (IOException localIOException)
    {
      for (;;) {}
    }
  }

  protected HttpRequest closeOutputQuietly()
    throws HttpRequest.HttpRequestException
  {
    try
    {
      HttpRequest localHttpRequest = closeOutput();
      return localHttpRequest;
    }
    catch (IOException localIOException)
    {
      throw new HttpRequestException(localIOException);
    }
  }

  public int code()
    throws HttpRequest.HttpRequestException
  {
    try
    {
      closeOutput();
      int i = getConnection().getResponseCode();
      return i;
    }
    catch (IOException localIOException)
    {
      throw new HttpRequestException(localIOException);
    }
  }

  public HttpRequest code(AtomicInteger paramAtomicInteger)
    throws HttpRequest.HttpRequestException
  {
    paramAtomicInteger.set(code());
    return this;
  }

  public HttpRequest connectTimeout(int paramInt)
  {
    getConnection().setConnectTimeout(paramInt);
    return this;
  }

  public String contentEncoding()
  {
    return header("Content-Encoding");
  }

  public int contentLength()
  {
    return intHeader("Content-Length");
  }

  public HttpRequest contentLength(int paramInt)
  {
    getConnection().setFixedLengthStreamingMode(paramInt);
    return this;
  }

  public HttpRequest contentLength(String paramString)
  {
    return contentLength(Integer.parseInt(paramString));
  }

  public HttpRequest contentType(String paramString)
  {
    return contentType(paramString, null);
  }

  public HttpRequest contentType(String paramString1, String paramString2)
  {
    if ((paramString2 != null) && (paramString2.length() > 0)) {
      return header("Content-Type", paramString1 + "; charset=" + paramString2);
    }
    return header("Content-Type", paramString1);
  }

  public String contentType()
  {
    return header("Content-Type");
  }

  protected HttpRequest copy(final InputStream paramInputStream, final OutputStream paramOutputStream)
    throws IOException
  {
    (HttpRequest)new CloseOperation(paramInputStream, this.ignoreCloseExceptions)
    {
      public HttpRequest run()
        throws IOException
      {
        byte[] arrayOfByte = new byte[HttpRequest.this.bufferSize];
        for (;;)
        {
          int i = paramInputStream.read(arrayOfByte);
          if (i == -1) {
            return HttpRequest.this;
          }
          paramOutputStream.write(arrayOfByte, 0, i);
          HttpRequest localHttpRequest = HttpRequest.this;
          localHttpRequest.totalWritten += i;
          HttpRequest.this.progress.onUpload(HttpRequest.this.totalWritten, HttpRequest.this.totalSize);
        }
      }
    }.call();
  }

  protected HttpRequest copy(final Reader paramReader, final Writer paramWriter)
    throws IOException
  {
    (HttpRequest)new CloseOperation(paramReader, this.ignoreCloseExceptions)
    {
      public HttpRequest run()
        throws IOException
      {
        char[] arrayOfChar = new char[HttpRequest.this.bufferSize];
        for (;;)
        {
          int i = paramReader.read(arrayOfChar);
          if (i == -1) {
            return HttpRequest.this;
          }
          paramWriter.write(arrayOfChar, 0, i);
          HttpRequest localHttpRequest = HttpRequest.this;
          localHttpRequest.totalWritten += i;
          HttpRequest.this.progress.onUpload(HttpRequest.this.totalWritten, -1L);
        }
      }
    }.call();
  }

  public boolean created()
    throws HttpRequest.HttpRequestException
  {
    return 201 == code();
  }

  public long date()
  {
    return dateHeader("Date");
  }

  public long dateHeader(String paramString)
    throws HttpRequest.HttpRequestException
  {
    return dateHeader(paramString, -1L);
  }

  public long dateHeader(String paramString, long paramLong)
    throws HttpRequest.HttpRequestException
  {
    closeOutputQuietly();
    return getConnection().getHeaderFieldDate(paramString, paramLong);
  }

  public HttpRequest disconnect()
  {
    getConnection().disconnect();
    return this;
  }

  public String eTag()
  {
    return header("ETag");
  }

  public long expires()
  {
    return dateHeader("Expires");
  }

  public HttpRequest followRedirects(boolean paramBoolean)
  {
    getConnection().setInstanceFollowRedirects(paramBoolean);
    return this;
  }

  public HttpRequest form(Object paramObject1, Object paramObject2)
    throws HttpRequest.HttpRequestException
  {
    return form(paramObject1, paramObject2, "UTF-8");
  }

  public HttpRequest form(Object paramObject1, Object paramObject2, String paramString)
    throws HttpRequest.HttpRequestException
  {
    if (this.form) {}
    for (int i = 0;; i = 1)
    {
      if (i != 0)
      {
        contentType("application/x-www-form-urlencoded", paramString);
        this.form = true;
      }
      paramString = getValidCharset(paramString);
      try
      {
        openOutput();
        if (i == 0) {
          this.output.write(38);
        }
        this.output.write(URLEncoder.encode(paramObject1.toString(), paramString));
        this.output.write(61);
        if (paramObject2 != null) {
          this.output.write(URLEncoder.encode(paramObject2.toString(), paramString));
        }
        return this;
      }
      catch (IOException paramObject1)
      {
        throw new HttpRequestException((IOException)paramObject1);
      }
    }
  }

  public HttpRequest form(Map.Entry<?, ?> paramEntry)
    throws HttpRequest.HttpRequestException
  {
    return form(paramEntry, "UTF-8");
  }

  public HttpRequest form(Map.Entry<?, ?> paramEntry, String paramString)
    throws HttpRequest.HttpRequestException
  {
    return form(paramEntry.getKey(), paramEntry.getValue(), paramString);
  }

  public HttpRequest form(Map<?, ?> paramMap)
    throws HttpRequest.HttpRequestException
  {
    return form(paramMap, "UTF-8");
  }

  public HttpRequest form(Map<?, ?> paramMap, String paramString)
    throws HttpRequest.HttpRequestException
  {
    if (!paramMap.isEmpty()) {
      paramMap = paramMap.entrySet().iterator();
    }
    for (;;)
    {
      if (!paramMap.hasNext()) {
        return this;
      }
      form((Map.Entry)paramMap.next(), paramString);
    }
  }

  public HttpURLConnection getConnection()
  {
    if (this.connection == null) {
      this.connection = createConnection();
    }
    return this.connection;
  }

  protected String getParam(String paramString1, String paramString2)
  {
    if ((paramString1 == null) || (paramString1.length() == 0))
    {
      paramString1 = null;
      return paramString1;
    }
    int j = paramString1.length();
    int m = paramString1.indexOf(';') + 1;
    if ((m == 0) || (m == j)) {
      return null;
    }
    int n = paramString1.indexOf(';', m);
    int i = n;
    int k = m;
    if (n == -1)
    {
      i = j;
      k = m;
    }
    for (;;)
    {
      if (k >= i) {
        return null;
      }
      m = paramString1.indexOf('=', k);
      if ((m != -1) && (m < i) && (paramString2.equals(paramString1.substring(k, m).trim())))
      {
        String str = paramString1.substring(m + 1, i).trim();
        k = str.length();
        if (k != 0)
        {
          paramString1 = str;
          if (k <= 2) {
            break;
          }
          paramString1 = str;
          if ('"' != str.charAt(0)) {
            break;
          }
          paramString1 = str;
          if ('"' != str.charAt(k - 1)) {
            break;
          }
          return str.substring(1, k - 1);
        }
      }
      m = i + 1;
      n = paramString1.indexOf(';', m);
      i = n;
      k = m;
      if (n == -1)
      {
        i = j;
        k = m;
      }
    }
  }

  protected Map<String, String> getParams(String paramString)
  {
    Object localObject;
    if ((paramString == null) || (paramString.length() == 0)) {
      localObject = Collections.emptyMap();
    }
    int j;
    int k;
    int i;
    LinkedHashMap localLinkedHashMap;
    do
    {
      return (Map<String, String>)localObject;
      j = paramString.length();
      k = paramString.indexOf(';') + 1;
      if ((k == 0) || (k == j)) {
        return Collections.emptyMap();
      }
      m = paramString.indexOf(';', k);
      i = m;
      if (m == -1) {
        i = j;
      }
      localLinkedHashMap = new LinkedHashMap();
      localObject = localLinkedHashMap;
    } while (k >= i);
    int m = paramString.indexOf('=', k);
    String str;
    if ((m != -1) && (m < i))
    {
      localObject = paramString.substring(k, m).trim();
      if (((String)localObject).length() > 0)
      {
        str = paramString.substring(m + 1, i).trim();
        k = str.length();
        if (k != 0)
        {
          if ((k <= 2) || ('"' != str.charAt(0)) || ('"' != str.charAt(k - 1))) {
            break label249;
          }
          localLinkedHashMap.put(localObject, str.substring(1, k - 1));
        }
      }
    }
    for (;;)
    {
      m = i + 1;
      int n = paramString.indexOf(';', m);
      i = n;
      k = m;
      if (n != -1) {
        break;
      }
      i = j;
      k = m;
      break;
      label249:
      localLinkedHashMap.put(localObject, str);
    }
  }

  public HttpRequest header(String paramString, Number paramNumber)
  {
    if (paramNumber != null) {}
    for (paramNumber = paramNumber.toString();; paramNumber = null) {
      return header(paramString, paramNumber);
    }
  }

  public HttpRequest header(String paramString1, String paramString2)
  {
    getConnection().setRequestProperty(paramString1, paramString2);
    return this;
  }

  public HttpRequest header(Map.Entry<String, String> paramEntry)
  {
    return header((String)paramEntry.getKey(), (String)paramEntry.getValue());
  }

  public String header(String paramString)
    throws HttpRequest.HttpRequestException
  {
    closeOutputQuietly();
    return getConnection().getHeaderField(paramString);
  }

  public HttpRequest headers(Map<String, String> paramMap)
  {
    if (!paramMap.isEmpty()) {
      paramMap = paramMap.entrySet().iterator();
    }
    for (;;)
    {
      if (!paramMap.hasNext()) {
        return this;
      }
      header((Map.Entry)paramMap.next());
    }
  }

  public Map<String, List<String>> headers()
    throws HttpRequest.HttpRequestException
  {
    closeOutputQuietly();
    return getConnection().getHeaderFields();
  }

  public String[] headers(String paramString)
  {
    Map localMap = headers();
    if ((localMap == null) || (localMap.isEmpty())) {
      return EMPTY_STRINGS;
    }
    paramString = (List)localMap.get(paramString);
    if ((paramString != null) && (!paramString.isEmpty())) {
      return (String[])paramString.toArray(new String[paramString.size()]);
    }
    return EMPTY_STRINGS;
  }

  public HttpRequest ifModifiedSince(long paramLong)
  {
    getConnection().setIfModifiedSince(paramLong);
    return this;
  }

  public HttpRequest ifNoneMatch(String paramString)
  {
    return header("If-None-Match", paramString);
  }

  public HttpRequest ignoreCloseExceptions(boolean paramBoolean)
  {
    this.ignoreCloseExceptions = paramBoolean;
    return this;
  }

  public boolean ignoreCloseExceptions()
  {
    return this.ignoreCloseExceptions;
  }

  public int intHeader(String paramString)
    throws HttpRequest.HttpRequestException
  {
    return intHeader(paramString, -1);
  }

  public int intHeader(String paramString, int paramInt)
    throws HttpRequest.HttpRequestException
  {
    closeOutputQuietly();
    return getConnection().getHeaderFieldInt(paramString, paramInt);
  }

  public boolean isBodyEmpty()
    throws HttpRequest.HttpRequestException
  {
    return contentLength() == 0;
  }

  public long lastModified()
  {
    return dateHeader("Last-Modified");
  }

  public String location()
  {
    return header("Location");
  }

  public String message()
    throws HttpRequest.HttpRequestException
  {
    try
    {
      closeOutput();
      String str = getConnection().getResponseMessage();
      return str;
    }
    catch (IOException localIOException)
    {
      throw new HttpRequestException(localIOException);
    }
  }

  public String method()
  {
    return getConnection().getRequestMethod();
  }

  public boolean noContent()
    throws HttpRequest.HttpRequestException
  {
    return 204 == code();
  }

  public boolean notFound()
    throws HttpRequest.HttpRequestException
  {
    return 404 == code();
  }

  public boolean notModified()
    throws HttpRequest.HttpRequestException
  {
    return 304 == code();
  }

  public boolean ok()
    throws HttpRequest.HttpRequestException
  {
    return 200 == code();
  }

  protected HttpRequest openOutput()
    throws IOException
  {
    if (this.output != null) {
      return this;
    }
    getConnection().setDoOutput(true);
    String str = getParam(getConnection().getRequestProperty("Content-Type"), "charset");
    this.output = new RequestOutputStream(getConnection().getOutputStream(), str, this.bufferSize);
    return this;
  }

  public String parameter(String paramString1, String paramString2)
  {
    return getParam(header(paramString1), paramString2);
  }

  public Map<String, String> parameters(String paramString)
  {
    return getParams(header(paramString));
  }

  public HttpRequest part(String paramString, File paramFile)
    throws HttpRequest.HttpRequestException
  {
    return part(paramString, null, paramFile);
  }

  public HttpRequest part(String paramString, InputStream paramInputStream)
    throws HttpRequest.HttpRequestException
  {
    return part(paramString, null, null, paramInputStream);
  }

  public HttpRequest part(String paramString, Number paramNumber)
    throws HttpRequest.HttpRequestException
  {
    return part(paramString, null, paramNumber);
  }

  public HttpRequest part(String paramString1, String paramString2)
  {
    return part(paramString1, null, paramString2);
  }

  public HttpRequest part(String paramString1, String paramString2, File paramFile)
    throws HttpRequest.HttpRequestException
  {
    return part(paramString1, paramString2, null, paramFile);
  }

  public HttpRequest part(String paramString1, String paramString2, Number paramNumber)
    throws HttpRequest.HttpRequestException
  {
    if (paramNumber != null) {}
    for (paramNumber = paramNumber.toString();; paramNumber = null) {
      return part(paramString1, paramString2, paramNumber);
    }
  }

  public HttpRequest part(String paramString1, String paramString2, String paramString3)
    throws HttpRequest.HttpRequestException
  {
    return part(paramString1, paramString2, null, paramString3);
  }

  public HttpRequest part(String paramString1, String paramString2, String paramString3, File paramFile)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      BufferedInputStream localBufferedInputStream = new BufferedInputStream(new FileInputStream(paramFile));
      incrementTotalSize(paramFile.length());
      return part(paramString1, paramString2, paramString3, localBufferedInputStream);
    }
    catch (IOException paramString1)
    {
      throw new HttpRequestException(paramString1);
    }
  }

  public HttpRequest part(String paramString1, String paramString2, String paramString3, InputStream paramInputStream)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      startPart();
      writePartHeader(paramString1, paramString2, paramString3);
      copy(paramInputStream, this.output);
      return this;
    }
    catch (IOException paramString1)
    {
      throw new HttpRequestException(paramString1);
    }
  }

  public HttpRequest part(String paramString1, String paramString2, String paramString3, String paramString4)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      startPart();
      writePartHeader(paramString1, paramString2, paramString3);
      this.output.write(paramString4);
      return this;
    }
    catch (IOException paramString1)
    {
      throw new HttpRequestException(paramString1);
    }
  }

  public HttpRequest partHeader(String paramString1, String paramString2)
    throws HttpRequest.HttpRequestException
  {
    return send(paramString1).send(": ").send(paramString2).send("\r\n");
  }

  public HttpRequest progress(UploadProgress paramUploadProgress)
  {
    if (paramUploadProgress == null)
    {
      this.progress = UploadProgress.DEFAULT;
      return this;
    }
    this.progress = paramUploadProgress;
    return this;
  }

  public HttpRequest proxyAuthorization(String paramString)
  {
    return header("Proxy-Authorization", paramString);
  }

  public HttpRequest proxyBasic(String paramString1, String paramString2)
  {
    return proxyAuthorization("Basic " + Base64.encode(new StringBuilder(String.valueOf(paramString1)).append(':').append(paramString2).toString()));
  }

  public HttpRequest readTimeout(int paramInt)
  {
    getConnection().setReadTimeout(paramInt);
    return this;
  }

  public InputStreamReader reader()
    throws HttpRequest.HttpRequestException
  {
    return reader(charset());
  }

  public InputStreamReader reader(String paramString)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      paramString = new InputStreamReader(stream(), getValidCharset(paramString));
      return paramString;
    }
    catch (UnsupportedEncodingException paramString)
    {
      throw new HttpRequestException(paramString);
    }
  }

  public HttpRequest receive(final File paramFile)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      paramFile = new BufferedOutputStream(new FileOutputStream(paramFile), this.bufferSize);
      (HttpRequest)new CloseOperation(paramFile, this.ignoreCloseExceptions)
      {
        protected HttpRequest run()
          throws HttpRequest.HttpRequestException, IOException
        {
          return HttpRequest.this.receive(paramFile);
        }
      }.call();
    }
    catch (FileNotFoundException paramFile)
    {
      throw new HttpRequestException(paramFile);
    }
  }

  public HttpRequest receive(OutputStream paramOutputStream)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      paramOutputStream = copy(buffer(), paramOutputStream);
      return paramOutputStream;
    }
    catch (IOException paramOutputStream)
    {
      throw new HttpRequestException(paramOutputStream);
    }
  }

  public HttpRequest receive(PrintStream paramPrintStream)
    throws HttpRequest.HttpRequestException
  {
    return receive(paramPrintStream);
  }

  public HttpRequest receive(final Writer paramWriter)
    throws HttpRequest.HttpRequestException
  {
    final BufferedReader localBufferedReader = bufferedReader();
    (HttpRequest)new CloseOperation(localBufferedReader, this.ignoreCloseExceptions)
    {
      public HttpRequest run()
        throws IOException
      {
        return HttpRequest.this.copy(localBufferedReader, paramWriter);
      }
    }.call();
  }

  public HttpRequest receive(final Appendable paramAppendable)
    throws HttpRequest.HttpRequestException
  {
    final BufferedReader localBufferedReader = bufferedReader();
    (HttpRequest)new CloseOperation(localBufferedReader, this.ignoreCloseExceptions)
    {
      public HttpRequest run()
        throws IOException
      {
        CharBuffer localCharBuffer = CharBuffer.allocate(HttpRequest.this.bufferSize);
        for (;;)
        {
          int i = localBufferedReader.read(localCharBuffer);
          if (i == -1) {
            return HttpRequest.this;
          }
          localCharBuffer.rewind();
          paramAppendable.append(localCharBuffer, 0, i);
          localCharBuffer.rewind();
        }
      }
    }.call();
  }

  public HttpRequest referer(String paramString)
  {
    return header("Referer", paramString);
  }

  public HttpRequest send(File paramFile)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      BufferedInputStream localBufferedInputStream = new BufferedInputStream(new FileInputStream(paramFile));
      incrementTotalSize(paramFile.length());
      return send(localBufferedInputStream);
    }
    catch (FileNotFoundException paramFile)
    {
      throw new HttpRequestException(paramFile);
    }
  }

  public HttpRequest send(InputStream paramInputStream)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      openOutput();
      copy(paramInputStream, this.output);
      return this;
    }
    catch (IOException paramInputStream)
    {
      throw new HttpRequestException(paramInputStream);
    }
  }

  public HttpRequest send(final Reader paramReader)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      openOutput();
      final OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(this.output, this.output.encoder.charset());
      (HttpRequest)new FlushOperation(localOutputStreamWriter)
      {
        protected HttpRequest run()
          throws IOException
        {
          return HttpRequest.this.copy(paramReader, localOutputStreamWriter);
        }
      }.call();
    }
    catch (IOException paramReader)
    {
      throw new HttpRequestException(paramReader);
    }
  }

  public HttpRequest send(CharSequence paramCharSequence)
    throws HttpRequest.HttpRequestException
  {
    try
    {
      openOutput();
      this.output.write(paramCharSequence.toString());
      return this;
    }
    catch (IOException paramCharSequence)
    {
      throw new HttpRequestException(paramCharSequence);
    }
  }

  public HttpRequest send(byte[] paramArrayOfByte)
    throws HttpRequest.HttpRequestException
  {
    if (paramArrayOfByte != null) {
      incrementTotalSize(paramArrayOfByte.length);
    }
    return send(new ByteArrayInputStream(paramArrayOfByte));
  }

  public String server()
  {
    return header("Server");
  }

  public boolean serverError()
    throws HttpRequest.HttpRequestException
  {
    return 500 == code();
  }

  protected HttpRequest startPart()
    throws IOException
  {
    if (!this.multipart)
    {
      this.multipart = true;
      contentType("multipart/form-data; boundary=00content0boundary00").openOutput();
      this.output.write("--00content0boundary00\r\n");
      return this;
    }
    this.output.write("\r\n--00content0boundary00\r\n");
    return this;
  }

  public InputStream stream()
    throws HttpRequest.HttpRequestException
  {
    if (code() < 400) {}
    Object localObject2;
    for (;;)
    {
      try
      {
        InputStream localInputStream1 = getConnection().getInputStream();
        if ((this.uncompress) && ("gzip".equals(contentEncoding()))) {
          break;
        }
        return localInputStream1;
      }
      catch (IOException localIOException1)
      {
        throw new HttpRequestException(localIOException1);
      }
      InputStream localInputStream2 = getConnection().getErrorStream();
      Object localObject1 = localInputStream2;
      if (localInputStream2 == null) {
        try
        {
          localObject1 = getConnection().getInputStream();
        }
        catch (IOException localIOException2)
        {
          if (contentLength() > 0) {
            throw new HttpRequestException(localIOException2);
          }
          localObject2 = new ByteArrayInputStream(new byte[0]);
        }
      }
    }
    try
    {
      localObject2 = new GZIPInputStream((InputStream)localObject2);
      return (InputStream)localObject2;
    }
    catch (IOException localIOException3)
    {
      throw new HttpRequestException(localIOException3);
    }
  }

  public String toString()
  {
    return method() + ' ' + url();
  }

  public HttpRequest trustAllCerts()
    throws HttpRequest.HttpRequestException
  {
    HttpURLConnection localHttpURLConnection = getConnection();
    if ((localHttpURLConnection instanceof HttpsURLConnection)) {
      ((HttpsURLConnection)localHttpURLConnection).setSSLSocketFactory(getTrustedFactory());
    }
    return this;
  }

  public HttpRequest trustAllHosts()
  {
    HttpURLConnection localHttpURLConnection = getConnection();
    if ((localHttpURLConnection instanceof HttpsURLConnection)) {
      ((HttpsURLConnection)localHttpURLConnection).setHostnameVerifier(getTrustedVerifier());
    }
    return this;
  }

  public HttpRequest uncompress(boolean paramBoolean)
  {
    this.uncompress = paramBoolean;
    return this;
  }

  public URL url()
  {
    return getConnection().getURL();
  }

  public HttpRequest useCaches(boolean paramBoolean)
  {
    getConnection().setUseCaches(paramBoolean);
    return this;
  }

  public HttpRequest useProxy(String paramString, int paramInt)
  {
    if (this.connection != null) {
      throw new IllegalStateException("The connection has already been created. This method must be called before reading or writing to the request.");
    }
    this.httpProxyHost = paramString;
    this.httpProxyPort = paramInt;
    return this;
  }

  public HttpRequest userAgent(String paramString)
  {
    return header("User-Agent", paramString);
  }

  protected HttpRequest writePartHeader(String paramString1, String paramString2)
    throws IOException
  {
    return writePartHeader(paramString1, paramString2, null);
  }

  protected HttpRequest writePartHeader(String paramString1, String paramString2, String paramString3)
    throws IOException
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("form-data; name=\"").append(paramString1);
    if (paramString2 != null) {
      localStringBuilder.append("\"; filename=\"").append(paramString2);
    }
    localStringBuilder.append('"');
    partHeader("Content-Disposition", localStringBuilder.toString());
    if (paramString3 != null) {
      partHeader("Content-Type", paramString3);
    }
    return send("\r\n");
  }

  public OutputStreamWriter writer()
    throws HttpRequest.HttpRequestException
  {
    try
    {
      openOutput();
      OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(this.output, this.output.encoder.charset());
      return localOutputStreamWriter;
    }
    catch (IOException localIOException)
    {
      throw new HttpRequestException(localIOException);
    }
  }

  public static class Base64
  {
    private static final byte EQUALS_SIGN = 61;
    private static final String PREFERRED_ENCODING = "US-ASCII";
    private static final byte[] _STANDARD_ALPHABET = { 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, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47 };

    public static String encode(String paramString)
    {
      try
      {
        byte[] arrayOfByte = paramString.getBytes("US-ASCII");
        paramString = arrayOfByte;
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        for (;;)
        {
          paramString = paramString.getBytes();
        }
      }
      return encodeBytes(paramString);
    }

    private static byte[] encode3to4(byte[] paramArrayOfByte1, int paramInt1, int paramInt2, byte[] paramArrayOfByte2, int paramInt3)
    {
      int k = 0;
      byte[] arrayOfByte = _STANDARD_ALPHABET;
      int i;
      if (paramInt2 > 0)
      {
        i = paramArrayOfByte1[paramInt1] << 24 >>> 8;
        label23:
        if (paramInt2 <= 1) {
          break label104;
        }
      }
      label104:
      for (int j = paramArrayOfByte1[(paramInt1 + 1)] << 24 >>> 16;; j = 0)
      {
        if (paramInt2 > 2) {
          k = paramArrayOfByte1[(paramInt1 + 2)] << 24 >>> 24;
        }
        paramInt1 = j | i | k;
        switch (paramInt2)
        {
        default:
          return paramArrayOfByte2;
          i = 0;
          break label23;
        }
      }
      paramArrayOfByte2[paramInt3] = arrayOfByte[(paramInt1 >>> 18)];
      paramArrayOfByte2[(paramInt3 + 1)] = arrayOfByte[(paramInt1 >>> 12 & 0x3F)];
      paramArrayOfByte2[(paramInt3 + 2)] = arrayOfByte[(paramInt1 >>> 6 & 0x3F)];
      paramArrayOfByte2[(paramInt3 + 3)] = arrayOfByte[(paramInt1 & 0x3F)];
      return paramArrayOfByte2;
      paramArrayOfByte2[paramInt3] = arrayOfByte[(paramInt1 >>> 18)];
      paramArrayOfByte2[(paramInt3 + 1)] = arrayOfByte[(paramInt1 >>> 12 & 0x3F)];
      paramArrayOfByte2[(paramInt3 + 2)] = arrayOfByte[(paramInt1 >>> 6 & 0x3F)];
      paramArrayOfByte2[(paramInt3 + 3)] = 61;
      return paramArrayOfByte2;
      paramArrayOfByte2[paramInt3] = arrayOfByte[(paramInt1 >>> 18)];
      paramArrayOfByte2[(paramInt3 + 1)] = arrayOfByte[(paramInt1 >>> 12 & 0x3F)];
      paramArrayOfByte2[(paramInt3 + 2)] = 61;
      paramArrayOfByte2[(paramInt3 + 3)] = 61;
      return paramArrayOfByte2;
    }

    public static String encodeBytes(byte[] paramArrayOfByte)
    {
      return encodeBytes(paramArrayOfByte, 0, paramArrayOfByte.length);
    }

    public static String encodeBytes(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    {
      paramArrayOfByte = encodeBytesToBytes(paramArrayOfByte, paramInt1, paramInt2);
      try
      {
        String str = new String(paramArrayOfByte, "US-ASCII");
        return str;
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
      return new String(paramArrayOfByte);
    }

    public static byte[] encodeBytesToBytes(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    {
      if (paramArrayOfByte == null) {
        throw new NullPointerException("Cannot serialize a null array.");
      }
      if (paramInt1 < 0) {
        throw new IllegalArgumentException("Cannot have negative offset: " + paramInt1);
      }
      if (paramInt2 < 0) {
        throw new IllegalArgumentException("Cannot have length offset: " + paramInt2);
      }
      if (paramInt1 + paramInt2 > paramArrayOfByte.length) {
        throw new IllegalArgumentException(String.format("Cannot have offset of %d and length of %d with array of length %d", new Object[] { Integer.valueOf(paramInt1), Integer.valueOf(paramInt2), Integer.valueOf(paramArrayOfByte.length) }));
      }
      int j = paramInt2 / 3;
      int i;
      byte[] arrayOfByte;
      if (paramInt2 % 3 > 0)
      {
        i = 4;
        arrayOfByte = new byte[j * 4 + i];
        j = 0;
        i = 0;
      }
      for (;;)
      {
        if (j >= paramInt2 - 2)
        {
          int k = i;
          if (j < paramInt2)
          {
            encode3to4(paramArrayOfByte, j + paramInt1, paramInt2 - j, arrayOfByte, i);
            k = i + 4;
          }
          if (k > arrayOfByte.length - 1) {
            return arrayOfByte;
          }
          paramArrayOfByte = new byte[k];
          System.arraycopy(arrayOfByte, 0, paramArrayOfByte, 0, k);
          return paramArrayOfByte;
          i = 0;
          break;
        }
        encode3to4(paramArrayOfByte, j + paramInt1, 3, arrayOfByte, i);
        j += 3;
        i += 4;
      }
      return arrayOfByte;
    }
  }

  protected static abstract class CloseOperation<V>
    extends HttpRequest.Operation<V>
  {
    private final Closeable closeable;
    private final boolean ignoreCloseExceptions;

    protected CloseOperation(Closeable paramCloseable, boolean paramBoolean)
    {
      this.closeable = paramCloseable;
      this.ignoreCloseExceptions = paramBoolean;
    }

    protected void done()
      throws IOException
    {
      if ((this.closeable instanceof Flushable)) {
        ((Flushable)this.closeable).flush();
      }
      if (this.ignoreCloseExceptions) {}
      try
      {
        this.closeable.close();
        return;
      }
      catch (IOException localIOException) {}
      this.closeable.close();
      return;
    }
  }

  public static abstract interface ConnectionFactory
  {
    public static final ConnectionFactory DEFAULT = new ConnectionFactory()
    {
      public HttpURLConnection create(URL paramAnonymousURL)
        throws IOException
      {
        return (HttpURLConnection)paramAnonymousURL.openConnection();
      }

      public HttpURLConnection create(URL paramAnonymousURL, Proxy paramAnonymousProxy)
        throws IOException
      {
        return (HttpURLConnection)paramAnonymousURL.openConnection(paramAnonymousProxy);
      }
    };

    public abstract HttpURLConnection create(URL paramURL)
      throws IOException;

    public abstract HttpURLConnection create(URL paramURL, Proxy paramProxy)
      throws IOException;
  }

  protected static abstract class FlushOperation<V>
    extends HttpRequest.Operation<V>
  {
    private final Flushable flushable;

    protected FlushOperation(Flushable paramFlushable)
    {
      this.flushable = paramFlushable;
    }

    protected void done()
      throws IOException
    {
      this.flushable.flush();
    }
  }

  public static class HttpRequestException
    extends RuntimeException
  {
    private static final long serialVersionUID = -1170466989781746231L;

    public HttpRequestException(IOException paramIOException)
    {
      super();
    }

    public IOException getCause()
    {
      return (IOException)super.getCause();
    }
  }

  protected static abstract class Operation<V>
    implements Callable<V>
  {
    /* Error */
    public V call()
      throws HttpRequest.HttpRequestException
    {
      // Byte code:
      //   0: iconst_0
      //   1: istore_3
      //   2: aload_0
      //   3: invokevirtual 24        com/yaag/timelimit/HttpRequest$Operation:run        ()Ljava/lang/Object;
      //   6: astore_1
      //   7: aload_0
      //   8: invokevirtual 27        com/yaag/timelimit/HttpRequest$Operation:done        ()V
      //   11: aload_1
      //   12: areturn
      //   13: astore_2
      //   14: iconst_0
      //   15: ifne -4 -> 11
      //   18: new 19        com/yaag/timelimit/HttpRequest$HttpRequestException
      //   21: dup
      //   22: aload_2
      //   23: invokespecial 30        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
      //   26: athrow
      //   27: astore_1
      //   28: iconst_1
      //   29: istore_3
      //   30: aload_1
      //   31: athrow
      //   32: astore_1
      //   33: aload_0
      //   34: invokevirtual 27        com/yaag/timelimit/HttpRequest$Operation:done        ()V
      //   37: aload_1
      //   38: athrow
      //   39: astore_1
      //   40: iconst_1
      //   41: istore_3
      //   42: new 19        com/yaag/timelimit/HttpRequest$HttpRequestException
      //   45: dup
      //   46: aload_1
      //   47: invokespecial 30        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
      //   50: athrow
      //   51: astore_2
      //   52: iload_3
      //   53: ifne -16 -> 37
      //   56: new 19        com/yaag/timelimit/HttpRequest$HttpRequestException
      //   59: dup
      //   60: aload_2
      //   61: invokespecial 30        com/yaag/timelimit/HttpRequest$HttpRequestException:<init>        (Ljava/io/IOException;)V
      //   64: athrow
      // Local variable table:
      //   start        length        slot        name        signature
      //   0        65        0        this        Operation
      //   6        6        1        localObject1        Object
      //   27        4        1        localHttpRequestException        HttpRequest.HttpRequestException
      //   32        6        1        localObject2        Object
      //   39        8        1        localIOException1        IOException
      //   13        10        2        localIOException2        IOException
      //   51        10        2        localIOException3        IOException
      //   1        52        3        i        int
      // Exception table:
      //   from        to        target        type
      //   7        11        13        java/io/IOException
      //   2        7        27        com/yaag/timelimit/HttpRequest$HttpRequestException
      //   2        7        32        finally
      //   30        32        32        finally
      //   42        51        32        finally
      //   2        7        39        java/io/IOException
      //   33        37        51        java/io/IOException
    }

    protected abstract void done()
      throws IOException;

    protected abstract V run()
      throws HttpRequest.HttpRequestException, IOException;
  }

  public static class RequestOutputStream
    extends BufferedOutputStream
  {
    private final CharsetEncoder encoder;

    public RequestOutputStream(OutputStream paramOutputStream, String paramString, int paramInt)
    {
      super(paramInt);
      this.encoder = Charset.forName(HttpRequest.getValidCharset(paramString)).newEncoder();
    }

    public RequestOutputStream write(String paramString)
      throws IOException
    {
      paramString = this.encoder.encode(CharBuffer.wrap(paramString));
      super.write(paramString.array(), 0, paramString.limit());
      return this;
    }
  }

  public static abstract interface UploadProgress
  {
    public static final UploadProgress DEFAULT = new UploadProgress()
    {
      public void onUpload(long paramAnonymousLong1, long paramAnonymousLong2) {}
    };

    public abstract void onUpload(long paramLong1, long paramLong2);
  }
}

举报 使用道具

回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

0

关注

0

粉丝

129

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Archiver|手机版|java学习基地 |网站地图

GMT+8, 2021-3-7 20:49 , Processed in 0.656250 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.