Connection.java 21.3 KB
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
package com.squareup.okhttp;

import com.squareup.okhttp.internal.ConnectionSpecSelector;
import com.squareup.okhttp.internal.Platform;
import com.squareup.okhttp.internal.RouteDatabase;
import com.squareup.okhttp.internal.Util;
import com.squareup.okhttp.internal.Version;
import com.squareup.okhttp.internal.framed.FramedConnection;
import com.squareup.okhttp.internal.framed.FramedConnection.Builder;
import com.squareup.okhttp.internal.http.FramedTransport;
import com.squareup.okhttp.internal.http.HttpConnection;
import com.squareup.okhttp.internal.http.HttpEngine;
import com.squareup.okhttp.internal.http.HttpTransport;
import com.squareup.okhttp.internal.http.OkHeaders;
import com.squareup.okhttp.internal.http.RouteException;
import com.squareup.okhttp.internal.http.Transport;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.Socket;
import java.net.UnknownServiceException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.SocketFactory;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.Source;

public final class Connection
{
  private FramedConnection framedConnection;
  private Handshake handshake;
  private HttpConnection httpConnection;
  private long idleStartTimeNs;
  private Object owner;
  private final ConnectionPool pool;
  private Protocol protocol;
  private int recycleCount;
  private final Route route;
  private Socket socket;
  
  public Connection(ConnectionPool paramConnectionPool, Route paramRoute)
  {
    this.pool = paramConnectionPool;
    this.route = paramRoute;
  }
  
  private void connectSocket(int paramInt1, int paramInt2, int paramInt3, ConnectionSpecSelector paramConnectionSpecSelector)
    throws IOException
  {
    this.socket.setSoTimeout(paramInt2);
    Platform.get().connectSocket(this.socket, this.route.getSocketAddress(), paramInt1);
    if (this.route.address.getSslSocketFactory() != null) {
      connectTls(paramInt2, paramInt3, paramConnectionSpecSelector);
    }
    while ((this.protocol == Protocol.SPDY_3) || (this.protocol == Protocol.HTTP_2))
    {
      this.socket.setSoTimeout(0);
      this.framedConnection = new FramedConnection.Builder(this.route.address.uriHost, true, this.socket).protocol(this.protocol).build();
      this.framedConnection.sendConnectionPreface();
      return;
      this.protocol = Protocol.HTTP_1_1;
    }
    this.httpConnection = new HttpConnection(this.pool, this, this.socket);
  }
  
  /* Error */
  private void connectTls(int paramInt1, int paramInt2, ConnectionSpecSelector paramConnectionSpecSelector)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: aconst_null
    //   4: astore 7
    //   6: aconst_null
    //   7: astore 6
    //   9: aload_0
    //   10: getfield 33	com/squareup/okhttp/Connection:route	Lcom/squareup/okhttp/Route;
    //   13: invokevirtual 125	com/squareup/okhttp/Route:requiresTunnel	()Z
    //   16: ifeq +9 -> 25
    //   19: aload_0
    //   20: iload_1
    //   21: iload_2
    //   22: invokespecial 129	com/squareup/okhttp/Connection:createTunnel	(II)V
    //   25: aload_0
    //   26: getfield 33	com/squareup/okhttp/Connection:route	Lcom/squareup/okhttp/Route;
    //   29: invokevirtual 133	com/squareup/okhttp/Route:getAddress	()Lcom/squareup/okhttp/Address;
    //   32: astore 8
    //   34: aload 8
    //   36: invokevirtual 71	com/squareup/okhttp/Address:getSslSocketFactory	()Ljavax/net/ssl/SSLSocketFactory;
    //   39: astore 5
    //   41: aload 5
    //   43: aload_0
    //   44: getfield 40	com/squareup/okhttp/Connection:socket	Ljava/net/Socket;
    //   47: aload 8
    //   49: invokevirtual 137	com/squareup/okhttp/Address:getUriHost	()Ljava/lang/String;
    //   52: aload 8
    //   54: invokevirtual 141	com/squareup/okhttp/Address:getUriPort	()I
    //   57: iconst_1
    //   58: invokevirtual 147	javax/net/ssl/SSLSocketFactory:createSocket	(Ljava/net/Socket;Ljava/lang/String;IZ)Ljava/net/Socket;
    //   61: checkcast 149	javax/net/ssl/SSLSocket
    //   64: astore 5
    //   66: aload_3
    //   67: aload 5
    //   69: invokevirtual 155	com/squareup/okhttp/internal/ConnectionSpecSelector:configureSecureSocket	(Ljavax/net/ssl/SSLSocket;)Lcom/squareup/okhttp/ConnectionSpec;
    //   72: astore 6
    //   74: aload 6
    //   76: invokevirtual 160	com/squareup/okhttp/ConnectionSpec:supportsTlsExtensions	()Z
    //   79: ifeq +21 -> 100
    //   82: invokestatic 52	com/squareup/okhttp/internal/Platform:get	()Lcom/squareup/okhttp/internal/Platform;
    //   85: aload 5
    //   87: aload 8
    //   89: invokevirtual 137	com/squareup/okhttp/Address:getUriHost	()Ljava/lang/String;
    //   92: aload 8
    //   94: invokevirtual 164	com/squareup/okhttp/Address:getProtocols	()Ljava/util/List;
    //   97: invokevirtual 168	com/squareup/okhttp/internal/Platform:configureTlsExtensions	(Ljavax/net/ssl/SSLSocket;Ljava/lang/String;Ljava/util/List;)V
    //   100: aload 5
    //   102: invokevirtual 171	javax/net/ssl/SSLSocket:startHandshake	()V
    //   105: aload 5
    //   107: invokevirtual 175	javax/net/ssl/SSLSocket:getSession	()Ljavax/net/ssl/SSLSession;
    //   110: invokestatic 180	com/squareup/okhttp/Handshake:get	(Ljavax/net/ssl/SSLSession;)Lcom/squareup/okhttp/Handshake;
    //   113: astore 4
    //   115: aload 8
    //   117: invokevirtual 184	com/squareup/okhttp/Address:getHostnameVerifier	()Ljavax/net/ssl/HostnameVerifier;
    //   120: aload 8
    //   122: invokevirtual 137	com/squareup/okhttp/Address:getUriHost	()Ljava/lang/String;
    //   125: aload 5
    //   127: invokevirtual 175	javax/net/ssl/SSLSocket:getSession	()Ljavax/net/ssl/SSLSession;
    //   130: invokeinterface 190 3 0
    //   135: ifne +141 -> 276
    //   138: aload 4
    //   140: invokevirtual 193	com/squareup/okhttp/Handshake:peerCertificates	()Ljava/util/List;
    //   143: iconst_0
    //   144: invokeinterface 198 2 0
    //   149: checkcast 200	java/security/cert/X509Certificate
    //   152: astore_3
    //   153: new 202	javax/net/ssl/SSLPeerUnverifiedException
    //   156: dup
    //   157: new 204	java/lang/StringBuilder
    //   160: dup
    //   161: ldc -50
    //   163: invokespecial 209	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   166: aload 8
    //   168: invokevirtual 137	com/squareup/okhttp/Address:getUriHost	()Ljava/lang/String;
    //   171: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   174: ldc -41
    //   176: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   179: aload_3
    //   180: invokestatic 221	com/squareup/okhttp/CertificatePinner:pin	(Ljava/security/cert/Certificate;)Ljava/lang/String;
    //   183: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   186: ldc -33
    //   188: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   191: aload_3
    //   192: invokevirtual 227	java/security/cert/X509Certificate:getSubjectDN	()Ljava/security/Principal;
    //   195: invokeinterface 232 1 0
    //   200: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   203: ldc -22
    //   205: invokevirtual 213	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   208: aload_3
    //   209: invokestatic 240	com/squareup/okhttp/internal/tls/OkHostnameVerifier:allSubjectAltNames	(Ljava/security/cert/X509Certificate;)Ljava/util/List;
    //   212: invokevirtual 243	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   215: invokevirtual 246	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   218: invokespecial 247	javax/net/ssl/SSLPeerUnverifiedException:<init>	(Ljava/lang/String;)V
    //   221: athrow
    //   222: astore 4
    //   224: aload 5
    //   226: astore_3
    //   227: aload 4
    //   229: astore 5
    //   231: aload_3
    //   232: astore 4
    //   234: aload 5
    //   236: invokestatic 253	com/squareup/okhttp/internal/Util:isAndroidGetsocknameError	(Ljava/lang/AssertionError;)Z
    //   239: ifeq +122 -> 361
    //   242: aload_3
    //   243: astore 4
    //   245: new 38	java/io/IOException
    //   248: dup
    //   249: aload 5
    //   251: invokespecial 256	java/io/IOException:<init>	(Ljava/lang/Throwable;)V
    //   254: athrow
    //   255: astore_3
    //   256: aload 4
    //   258: ifnull +11 -> 269
    //   261: invokestatic 52	com/squareup/okhttp/internal/Platform:get	()Lcom/squareup/okhttp/internal/Platform;
    //   264: aload 4
    //   266: invokevirtual 260	com/squareup/okhttp/internal/Platform:afterHandshake	(Ljavax/net/ssl/SSLSocket;)V
    //   269: aload 4
    //   271: invokestatic 264	com/squareup/okhttp/internal/Util:closeQuietly	(Ljava/net/Socket;)V
    //   274: aload_3
    //   275: athrow
    //   276: aload 8
    //   278: invokevirtual 268	com/squareup/okhttp/Address:getCertificatePinner	()Lcom/squareup/okhttp/CertificatePinner;
    //   281: aload 8
    //   283: invokevirtual 137	com/squareup/okhttp/Address:getUriHost	()Ljava/lang/String;
    //   286: aload 4
    //   288: invokevirtual 193	com/squareup/okhttp/Handshake:peerCertificates	()Ljava/util/List;
    //   291: invokevirtual 272	com/squareup/okhttp/CertificatePinner:check	(Ljava/lang/String;Ljava/util/List;)V
    //   294: aload 7
    //   296: astore_3
    //   297: aload 6
    //   299: invokevirtual 160	com/squareup/okhttp/ConnectionSpec:supportsTlsExtensions	()Z
    //   302: ifeq +12 -> 314
    //   305: invokestatic 52	com/squareup/okhttp/internal/Platform:get	()Lcom/squareup/okhttp/internal/Platform;
    //   308: aload 5
    //   310: invokevirtual 276	com/squareup/okhttp/internal/Platform:getSelectedProtocol	(Ljavax/net/ssl/SSLSocket;)Ljava/lang/String;
    //   313: astore_3
    //   314: aload_0
    //   315: aload 5
    //   317: putfield 40	com/squareup/okhttp/Connection:socket	Ljava/net/Socket;
    //   320: aload_0
    //   321: aload 4
    //   323: putfield 278	com/squareup/okhttp/Connection:handshake	Lcom/squareup/okhttp/Handshake;
    //   326: aload_3
    //   327: ifnull +27 -> 354
    //   330: aload_3
    //   331: invokestatic 281	com/squareup/okhttp/Protocol:get	(Ljava/lang/String;)Lcom/squareup/okhttp/Protocol;
    //   334: astore_3
    //   335: aload_0
    //   336: aload_3
    //   337: putfield 77	com/squareup/okhttp/Connection:protocol	Lcom/squareup/okhttp/Protocol;
    //   340: aload 5
    //   342: ifnull +11 -> 353
    //   345: invokestatic 52	com/squareup/okhttp/internal/Platform:get	()Lcom/squareup/okhttp/internal/Platform;
    //   348: aload 5
    //   350: invokevirtual 260	com/squareup/okhttp/internal/Platform:afterHandshake	(Ljavax/net/ssl/SSLSocket;)V
    //   353: return
    //   354: getstatic 111	com/squareup/okhttp/Protocol:HTTP_1_1	Lcom/squareup/okhttp/Protocol;
    //   357: astore_3
    //   358: goto -23 -> 335
    //   361: aload_3
    //   362: astore 4
    //   364: aload 5
    //   366: athrow
    //   367: astore_3
    //   368: aload 5
    //   370: astore 4
    //   372: goto -116 -> 256
    //   375: astore 5
    //   377: aload 6
    //   379: astore_3
    //   380: goto -149 -> 231
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	383	0	this	Connection
    //   0	383	1	paramInt1	int
    //   0	383	2	paramInt2	int
    //   0	383	3	paramConnectionSpecSelector	ConnectionSpecSelector
    //   1	138	4	localHandshake	Handshake
    //   222	6	4	localAssertionError1	AssertionError
    //   232	139	4	localObject1	Object
    //   39	330	5	localObject2	Object
    //   375	1	5	localAssertionError2	AssertionError
    //   7	371	6	localConnectionSpec	ConnectionSpec
    //   4	291	7	localObject3	Object
    //   32	250	8	localAddress	Address
    // Exception table:
    //   from	to	target	type
    //   66	100	222	java/lang/AssertionError
    //   100	222	222	java/lang/AssertionError
    //   276	294	222	java/lang/AssertionError
    //   297	314	222	java/lang/AssertionError
    //   314	326	222	java/lang/AssertionError
    //   330	335	222	java/lang/AssertionError
    //   335	340	222	java/lang/AssertionError
    //   354	358	222	java/lang/AssertionError
    //   41	66	255	finally
    //   234	242	255	finally
    //   245	255	255	finally
    //   364	367	255	finally
    //   66	100	367	finally
    //   100	222	367	finally
    //   276	294	367	finally
    //   297	314	367	finally
    //   314	326	367	finally
    //   330	335	367	finally
    //   335	340	367	finally
    //   354	358	367	finally
    //   41	66	375	java/lang/AssertionError
  }
  
  private void createTunnel(int paramInt1, int paramInt2)
    throws IOException
  {
    Object localObject1 = createTunnelRequest();
    HttpConnection localHttpConnection = new HttpConnection(this.pool, this, this.socket);
    localHttpConnection.setTimeouts(paramInt1, paramInt2);
    Object localObject2 = ((Request)localObject1).httpUrl();
    String str = "CONNECT " + ((HttpUrl)localObject2).host() + ":" + ((HttpUrl)localObject2).port() + " HTTP/1.1";
    do
    {
      localHttpConnection.writeRequest(((Request)localObject1).headers(), str);
      localHttpConnection.flush();
      localObject1 = localHttpConnection.readResponse().request((Request)localObject1).build();
      long l2 = OkHeaders.contentLength((Response)localObject1);
      long l1 = l2;
      if (l2 == -1L) {
        l1 = 0L;
      }
      localObject2 = localHttpConnection.newFixedLengthSource(l1);
      Util.skipAll((Source)localObject2, Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
      ((Source)localObject2).close();
      switch (((Response)localObject1).code())
      {
      default: 
        throw new IOException("Unexpected response code for CONNECT: " + ((Response)localObject1).code());
      case 200: 
        if (localHttpConnection.bufferSize() <= 0L) {
          break;
        }
        throw new IOException("TLS tunnel buffered too many bytes!");
      case 407: 
        localObject2 = OkHeaders.processAuthHeader(this.route.getAddress().getAuthenticator(), (Response)localObject1, this.route.getProxy());
        localObject1 = localObject2;
      }
    } while (localObject2 != null);
    throw new IOException("Failed to authenticate with proxy");
  }
  
  private Request createTunnelRequest()
    throws IOException
  {
    HttpUrl localHttpUrl = new HttpUrl.Builder().scheme("https").host(this.route.address.uriHost).port(this.route.address.uriPort).build();
    return new Request.Builder().url(localHttpUrl).header("Host", Util.hostHeader(localHttpUrl)).header("Proxy-Connection", "Keep-Alive").header("User-Agent", Version.userAgent()).build();
  }
  
  final boolean clearOwner()
  {
    synchronized (this.pool)
    {
      if (this.owner == null) {
        return false;
      }
      this.owner = null;
      return true;
    }
  }
  
  final void closeIfOwnedBy(Object paramObject)
    throws IOException
  {
    if (isFramed()) {
      throw new IllegalStateException();
    }
    synchronized (this.pool)
    {
      if (this.owner != paramObject) {
        return;
      }
      this.owner = null;
      if (this.socket != null)
      {
        this.socket.close();
        return;
      }
    }
  }
  
  final void connect(int paramInt1, int paramInt2, int paramInt3, List<ConnectionSpec> paramList, boolean paramBoolean)
    throws RouteException
  {
    if (this.protocol != null) {
      throw new IllegalStateException("already connected");
    }
    ConnectionSpecSelector localConnectionSpecSelector = new ConnectionSpecSelector(paramList);
    Proxy localProxy = this.route.getProxy();
    Address localAddress = this.route.getAddress();
    if ((this.route.address.getSslSocketFactory() == null) && (!paramList.contains(ConnectionSpec.CLEARTEXT))) {
      throw new RouteException(new UnknownServiceException("CLEARTEXT communication not supported: " + paramList));
    }
    for (;;)
    {
      try
      {
        localObject = new Socket(localProxy);
        this.socket = ((Socket)localObject);
        connectSocket(paramInt1, paramInt2, paramInt3, localConnectionSpecSelector);
      }
      catch (IOException localIOException)
      {
        Util.closeQuietly(this.socket);
        this.socket = null;
        this.handshake = null;
        this.protocol = null;
        this.httpConnection = null;
        this.framedConnection = null;
        if (paramList != null) {
          continue;
        }
        Object localObject = new RouteException(localIOException);
        if (!paramBoolean) {
          continue;
        }
        paramList = (List<ConnectionSpec>)localObject;
        if (localConnectionSpecSelector.connectionFailed(localIOException)) {
          continue;
        }
        throw ((Throwable)localObject);
        paramList.addConnectException(localIOException);
        localObject = paramList;
        continue;
      }
      if (this.protocol == null)
      {
        if ((localProxy.type() == Proxy.Type.DIRECT) || (localProxy.type() == Proxy.Type.HTTP)) {
          localObject = localAddress.getSocketFactory().createSocket();
        }
      }
      else
      {
        return;
        paramList = null;
      }
    }
  }
  
  final void connectAndSetOwner(OkHttpClient paramOkHttpClient, Object paramObject)
    throws RouteException
  {
    setOwner(paramObject);
    if (!isConnected())
    {
      paramObject = this.route.address.getConnectionSpecs();
      connect(paramOkHttpClient.getConnectTimeout(), paramOkHttpClient.getReadTimeout(), paramOkHttpClient.getWriteTimeout(), (List)paramObject, paramOkHttpClient.getRetryOnConnectionFailure());
      if (isFramed()) {
        paramOkHttpClient.getConnectionPool().share(this);
      }
      paramOkHttpClient.routeDatabase().connected(getRoute());
    }
    setTimeouts(paramOkHttpClient.getReadTimeout(), paramOkHttpClient.getWriteTimeout());
  }
  
  public final Handshake getHandshake()
  {
    return this.handshake;
  }
  
  final long getIdleStartTimeNs()
  {
    if (this.framedConnection == null) {
      return this.idleStartTimeNs;
    }
    return this.framedConnection.getIdleStartTimeNs();
  }
  
  final Object getOwner()
  {
    synchronized (this.pool)
    {
      Object localObject1 = this.owner;
      return localObject1;
    }
  }
  
  public final Protocol getProtocol()
  {
    if (this.protocol != null) {
      return this.protocol;
    }
    return Protocol.HTTP_1_1;
  }
  
  public final Route getRoute()
  {
    return this.route;
  }
  
  public final Socket getSocket()
  {
    return this.socket;
  }
  
  final void incrementRecycleCount()
  {
    this.recycleCount += 1;
  }
  
  final boolean isAlive()
  {
    return (!this.socket.isClosed()) && (!this.socket.isInputShutdown()) && (!this.socket.isOutputShutdown());
  }
  
  final boolean isConnected()
  {
    return this.protocol != null;
  }
  
  final boolean isFramed()
  {
    return this.framedConnection != null;
  }
  
  final boolean isIdle()
  {
    return (this.framedConnection == null) || (this.framedConnection.isIdle());
  }
  
  final boolean isReadable()
  {
    if (this.httpConnection != null) {
      return this.httpConnection.isReadable();
    }
    return true;
  }
  
  final Transport newTransport(HttpEngine paramHttpEngine)
    throws IOException
  {
    if (this.framedConnection != null) {
      return new FramedTransport(paramHttpEngine, this.framedConnection);
    }
    return new HttpTransport(paramHttpEngine, this.httpConnection);
  }
  
  final BufferedSink rawSink()
  {
    if (this.httpConnection == null) {
      throw new UnsupportedOperationException();
    }
    return this.httpConnection.rawSink();
  }
  
  final BufferedSource rawSource()
  {
    if (this.httpConnection == null) {
      throw new UnsupportedOperationException();
    }
    return this.httpConnection.rawSource();
  }
  
  final int recycleCount()
  {
    return this.recycleCount;
  }
  
  final void resetIdleStartTime()
  {
    if (this.framedConnection != null) {
      throw new IllegalStateException("framedConnection != null");
    }
    this.idleStartTimeNs = System.nanoTime();
  }
  
  final void setOwner(Object paramObject)
  {
    if (isFramed()) {
      return;
    }
    synchronized (this.pool)
    {
      if (this.owner != null) {
        throw new IllegalStateException("Connection already has an owner!");
      }
    }
    this.owner = paramObject;
  }
  
  final void setTimeouts(int paramInt1, int paramInt2)
    throws RouteException
  {
    if (this.protocol == null) {
      throw new IllegalStateException("not connected");
    }
    if (this.httpConnection != null) {}
    try
    {
      this.socket.setSoTimeout(paramInt1);
      this.httpConnection.setTimeouts(paramInt1, paramInt2);
      return;
    }
    catch (IOException localIOException)
    {
      throw new RouteException(localIOException);
    }
  }
  
  public final String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder("Connection{").append(this.route.address.uriHost).append(":").append(this.route.address.uriPort).append(", proxy=").append(this.route.proxy).append(" hostAddress=").append(this.route.inetSocketAddress.getAddress().getHostAddress()).append(" cipherSuite=");
    if (this.handshake != null) {}
    for (String str = this.handshake.cipherSuite();; str = "none") {
      return str + " protocol=" + this.protocol + '}';
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/Connection.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */